Devices & Components
Arduino Uno Rev3
LED (generic)
Jumper wires (generic)
Resistor 10k ohm
Photo resistor
Breadboard (generic)
Software & Tools
Arduino IDE
Project description
Code
sketch_mar11a.ino
arduino
This code basically checks if electricity is running through the photoresistor, and if there is, it should turn on the LED.
1int ledPin = 2; 2 3void setup() { 4 Serial.begin(9600); 5 pinMode(ledPin, OUTPUT); 6} 7 8void loop() { 9 int value = analogRead(A0); 10 11 Serial.println("Analog Value: "); 12 Serial.println(value); 13 14 if (value > 450) { 15 digitalWrite(ledPin, LOW); 16 } else { 17 digitalWrite(ledPin, HIGH); 18 } 19 20 delay(250); 21} 22
Downloadable files
Circuit Diagram
Wire up your circuits like this, and you should be good to go.
Circuit Diagram

Circuit Diagram
Wire up your circuits like this, and you should be good to go.
Circuit Diagram

Comments
Only logged in users can leave comments