Monday, March 1, 2010

Dark LDR, Turn on LED (Task 28)

Sinple program that reads the light levels from the LDR and will turn an LED if it is dark and off if it is light:

int reading;

void setup() {
pinMode(13,OUTPUT);
Serial.begin(9600);
}

void loop() {
reading = analogRead(0);
if (reading < 200) {digitalWrite(13,1);}
else
{digitalWrite(13,0);}
}

No comments:

Post a Comment