So I am trying to use an IR remote to start and stop a timer. I have the signal codes for the buttons I want to use and the timer starts when I press the start button but when I try to press the stop button the IR receiver signal light turns on but no value is printed to the serial monitor unlike before the timer starts. My understanding of the code makes me think this should work but it isn't. I don't think it design problem, I am pretty sure it is a coding problem.
#include <IRremote.h>
#include <IRremoteInt.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
word HEXnum;
double t = 0;
void setup()
{
lcd.begin(16, 2);
lcd.clear();
//lcd.print("Time: ");
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop()
{
//lcd.setCursor(6,0);
if (irrecv.decode(&results))
{
HEXnum = results.value;
Serial.println(HEXnum);
if (HEXnum == 9754 || HEXnum == 9755 || HEXnum == 41565)
{
for (double i = 0; i <= 10.01 ; i = i + .01)
{
t = i;
lcd.print((String(t)) + (String(" ")));
delay(5);
lcd.setCursor(0, 0);
irrecv.resume();
if (irrecv.decode(&results))
{
HEXnum = results.value;
Serial.println(HEXnum);
if (HEXnum == 57885 || HEXnum == 28031)
{
//i = 15;
lcd.print(t);
}
}
}
}
irrecv.resume(); // Receive the next value
delay(5);
}
}
That's the code.