hi dear, my problem is i press stop button from my remote , the continue still continue counting? how to stop it if i wan before counting number to 9999? can i skip count , i wan exit when i press my remote control exit key? how the sketch i write? pls help
#include "IRremote.h"
int RECV_PIN = 2;
decode_results results;
IRrecv irrecv(RECV_PIN);
unsigned long val;
int ledpin = 13;
#define leftkey 0xFF10EF
#define rightkey 0xFF5AA5
int count = 0;
String x = "";
int y = 0;
void setup() {
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(ledpin,OUTPUT);
// digitalWrite(ledpin,HIGH);
}
void loop() {
if (irrecv.decode(&results)){
val = results.value;
Serial.println(val);
irrecv.resume(); // important return
switch (results.value){
case leftkey:
digitalWrite(ledpin,HIGH);
Serial.println("Led On");
Counter();
Serial.print(count);
break;
case rightkey:
digitalWrite(ledpin,LOW);
Serial.println("Led off");
break;
}
}
}
void Counter(){
y = x.toInt();
for (int i = y; i <= 9999; i++) {
Serial.print("Remaining Time:");
Serial.print(i, DEC);
}
}