Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int lightPin = 0; // Analog Input
- int threshold = 500;
- // the setup routine runs once when you press reset:
- void setup() {
- // initialize the digital pin 13 as an output.
- Serial.begin(9600);
- pinMode(13, OUTPUT);
- }
- // the loop routine runs over and over again forever:
- void loop() {
- Serial.println(analogRead(lightPin));
- if(analogRead(lightPin) > threshold ){
- digitalWrite(13, HIGH);
- Serial.println("high");
- }else{
- digitalWrite(13, LOW);
- Serial.println("low");
- }
- delay(1000); // wait for a second
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement