hello all,
i working on project uses ir remote control up/ down counter ic. i'm working following code:
the problem experiencing when hit button on remote, program seems hold remote code , continually carries out switch case code. desired effect program take input, carry out switch case once, , wait next input. suggestions on can add code desired effect?
thank you
mike
i working on project uses ir remote control up/ down counter ic. i'm working following code:
code: [select]
#include <irremote.h>
int irpin = 11; // pin ir sensor
irrecv irrecv(irpin);
decode_results results;
void setup()
{
serial.begin(9600);
irrecv.enableirin(); // start receiver
pinmode(13, output);//counter up
pinmode(12, output);//counter down
pinmode(10, output);//reset
digitalwrite(10, high);
digitalwrite(10, low);//reset counters
}
void loop()
{
if (irrecv.decode(&results))
{
irrecv.resume(); // receive next value
}
switch(results.value)
{
case 1168:
// left up
digitalwrite(13, high); // turn led on (high voltage level)
delay(10); // wait second
digitalwrite(13, low); // turn led off making voltage low
delay(500); // wait second
break;
case 3216:
// left down
digitalwrite(12, high); // turn led on (high voltage level)
delay(10); // wait second
digitalwrite(12, low); // turn led off making voltage low
delay(500); // wait second
break;
case 1808:
// left +3
break;
case 304:
//left reset
break;
}
the problem experiencing when hit button on remote, program seems hold remote code , continually carries out switch case code. desired effect program take input, carry out switch case once, , wait next input. suggestions on can add code desired effect?
thank you
mike
x = results.value;
.
.
.
switch (x)
{
case 1168:
// left up
digitalwrite(13, high); // turn led on (high voltage level)
delay(10); // wait second
digitalwrite(13, low); // turn led off making voltage low
delay(500); // wait second
x = 0;
break;
.
.
.
.
.
.
switch (x)
{
case 1168:
// left up
digitalwrite(13, high); // turn led on (high voltage level)
delay(10); // wait second
digitalwrite(13, low); // turn led off making voltage low
delay(500); // wait second
x = 0;
break;
.
.
.
Arduino Forum > Using Arduino > Programming Questions > IR Remote coding question
arduino
Comments
Post a Comment