Описание 10 светодиодов управляются фоторезистором

Код программы:
/*
PhotoCell and LEDs created by ScottC on 23rd May 2011
-----------------------------------------------------*/
//PhotoResistor Pin (photoRPin)
//the analog pin the photoresistor is connected to
int photoRPin = 0;
void setup() {
for (int i=4; i<14; i++){
pinMode(i, OUTPUT); //sets the led pins 4 to 13 to output
}
}
void loop(){
//Ensure to turn off ALL LEDs before continuing
for (int i=4; i<14; i++){
digitalWrite(i, LOW);
}
/* Read the light Level
Adjust the value 120 to 600 to span 4 to 13
The values 120 and 600 may need to be widened to suit
the minimum and maximum light levels being read by the
Analog pin */
int lightLevel = map(analogRead(photoRPin), 120, 600, 4, 13);
// Make sure the value is between 4 and 13, to turn on an LED
int ledON = constrain(lightLevel, 4, 13);
//Blink the LED on
blink(ledON, 10,1);
}
// The blink function - used to turn the LEDs on and off
void blink(int LEDPin, int onTime, int offTime){
// Turn the LED on
digitalWrite(LEDPin, HIGH);
// Delay so that you can see the LED go On.
delay(onTime);
// Turn the LED Off
digitalWrite(LEDPin, LOW);
// Delay so that you can see the LED go On.
delay(offTime);
}

Скопируйте этот код в IDE и загрузите в Arduino