Hi,
So my project is basically I'm using a UNO board with a BTS7960 43A High Power Motor Driver board to control a motor. I want to control the motor with IR remote which is no problem as I have figured out how to do that using the usual switch commands as shown below.
void loop() **
{
** if (irrecv.decode(&results)) // have we received an IR signal?
** {**
** translateIR();**
** irrecv.resume(); // receive the next value**
** } **
}
void translateIR() // takes action based on IR code received
// describing Remote IR codes
{
** switch(results.value)**
** {**
** case 0: //change zero to your IR remote UP button number**
** lcd.clear();**
** lcd.print("UP");**
** break;**
** default:**
** lcd.clear();**
** lcd.print(" other button ");**
** }**
** delay(500); // Do not get immediate repeat**
But what I also want to do is add two trip lasers which I will use a Light sensor in order to act as limit switch to stop the motor when it reaches a certain point and trips the laser. I'm assuming you would add the trip condition to the switch statement as an additional "case" but not sure how to integrate it with the IR 'cases' in the code as the switch statement in the IR case is just looking for a remote code. Below is sort of the code I want to integrate into a switch 'case' but haven't had any luck on working out the best way to do it.
Thanks
short Detect = analogRead(Rec); //Constanly reading the module value
if(Detect < 500) //The Max value is 760, if someone passes it goes below that (every value lower than 700 can do the work)
detection = true; //The detection is triggered
if(detection==true)
{
do certain task
}