// pin assignments

int LED = 13;

int LDR = 0;

// variables

int base;

int threshold = 100;

// declare inputs and outputs

// and take a baseline reading

void setup() {

pinMode(LED, OUTPUT);

pinMode(LDR, INPUT);

base = analogRead(LDR);


// read from the analog input connected to the LDR

// and print the value to the serial port.

// the delay is only to avoid sending so much data

// as to make it unreadable.

void loop() {

int v = analogRead(LDR);

if (v > threshold) {

digitalWrite(LED, LOW);

} else {

digitalWrite(LED, HIGH);



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s