Created
November 15, 2017 01:08
-
-
Save esmarr58/abde6f079d94a4d9783e25756df3504b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int ledPin = 13; // choose pin for the LED | |
int inputPin = 2; // choose input pin (for Infrared sensor) | |
int val = 0; // variable for reading the pin status | |
void setup() | |
{ | |
pinMode(ledPin, OUTPUT); // declare LED as output | |
pinMode(inputPin, INPUT); // declare Infrared sensor as input | |
} | |
void loop(){ | |
val = digitalRead(inputPin); // read input value | |
if (val == HIGH) { // check if the input is HIGH | |
digitalWrite(ledPin, LOW); // turn LED OFF | |
} else { | |
digitalWrite(ledPin, HIGH); // turn LED ON | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment