// Create a pointer to the pin powering each LED and to the photoresistor int red = 3; int yellow = 5; int green = 6; int blue = 11; int ldr = A0; // Variable for reading the photoresistor status int ldrState = 0; void setup() { // Set the pins powering each LED to output mode pinMode(red, OUTPUT); pinMode(yellow, OUTPUT); pinMode(green, OUTPUT); pinMode(blue, OUTPUT); // Set the pin powering the photoresistor as an input pinMode(ldr, INPUT); } void loop() { // Read the state of the photoresistor ldrState = analogRead(ldr); // Check if the photoresistor is pressed. If it is, the ldrState is less than 250 in the conditions I am using. if (ldrState < 100) { // turn the LEDs on digitalWrite(red, HIGH); digitalWrite(yellow, HIGH); digitalWrite(green, HIGH); digitalWrite(blue, HIGH); } else { // turn the LEDs off digitalWrite(red, LOW); digitalWrite(yellow, LOW); digitalWrite(green, LOW); digitalWrite(blue, LOW); } }