You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
470 B
C++
22 lines
470 B
C++
int light = 0;
|
|
void setup() {
|
|
}
|
|
|
|
void loop() {
|
|
int ss = 30; // sample size for light sensor
|
|
int average = 0;
|
|
for (int x = 0; x < ss; x++) {
|
|
average += analogRead(light);
|
|
delay(1);
|
|
}
|
|
average /= ss;
|
|
String bitIn = "";
|
|
for(int x = 0; x <9; x++) {
|
|
bitIn += average >> x;
|
|
}
|
|
int a = bitIn.substring(0, 3).toInt();
|
|
int b = bitIn.substring(3, 6).toInt();
|
|
int c = bitIn.substring(6, 9).toInt();
|
|
// set LED strips to c, b, a (in order RGB)
|
|
}
|