Hi!
I'm using single code and ! would like to use two buttons. 1 to start while loop and 2 to stop it. I tried some code but I can't figure out what I did wrong.
#include <IRremote.h>
#define key1 0xFFA25D
#define key2 0xFF629D
#define ledpin 5
#define RECV_PIN 7
IRrecv irrecv(RECV_PIN);
decode_results results;
unsigned long key_value = 0;
void setup() {
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(ledpin, OUTPUT);
}
void loop() {
if (irrecv.decode(&results)) {
if (results.value == 0XFFFFFFFF)
results.value = key_value;
switch (results.value) {
case key1:
inf_loop1();
break;
case key2:
inf_loop2();
break;
}
key_value = results.value;
irrecv.resume();
}
}
void inf_loop1(void)
{
while (results.value = key2) {
for (int i = 0; i <= 255; i++)
{
analogWrite(ledpin, i);
Serial.println(i);
}
for (int i = 255; i >= 0; i--)
{
analogWrite(ledpin, i);
Serial.println(i);
}
break;
}
}
void inf_loop2(void)
{
digitalWrite(ledpin, 0);
Serial.println(0);
}