Hello, I am trying to design a ir motion sensor for which i am already following an ardiuno design build for. However don't know how to change the code appropriately.
current code link
this code seems to only activate the output when an object is in proximity however I want to change it so that the output will turn on when an object is detected and stay on until another object is detected. This will be for a LED lamp that I want to turn on with a wave of my hand and then turn it off with another wave of my hand. Any help is greatly appreciated. This is only my second arduino project and am definately a beginner. Thanks
Below is the current code for the existing project:
int ledPin = 13; //LED anode connected to digital pin 13
int inputPin = 2; //infrared proximity switch connected to digital pin 2
int val = 0; //this variable will read the value from the sensor
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); //LED is off
} else {
digitalWrite(ledPin, HIGH); //LED is turned on
}
}