// This example reads the level of ambient light from // a photoresistor. The more light is detected, the more // leds light up. int r = 1; // analog input pin with photoresistor void setup() { for (int i=0; i<8; i++) { // set digital pins 0-7 as outputs pinMode(i, OUTPUT); } } void loop() { int v = analogRead(r); // store analog input in variable v for (int i=0; i<8; i++) { if (v > 128 * i) { // switch on leds, depending on v digitalWrite(i, HIGH); } else { digitalWrite(i, LOW); } } }