Board: ARDUINO Micro
Library Version: 2.3.3 ( IRremote )
Protocol: NEC
Hello. Im working with NEC protocol on Apple remote control with enabled holding key with "Decoded NEC: FFFFFFFF (0 bits)".
I have conntected 2 arduino (one which are displaying code on serial monitor (arduino uno), second - driver which Im programming (arduino micro).
if (irrecv.decode(&results))
{
if (results.decode_type == NEC)
{
currentButtonCode = results.value;
if (currentButtonCode == 0xFFFFFFFF) {
currentButtonCode = lastButtonCode;
blokadaPilot=0;
} else {
lastButtonCode = currentButtonCode;
blokadaPilot=1;
}
if (results.value== Button3 && count == 0 && mute_pressed==0 && blokadaPilot==1)
{
vol = vol + 0.5;
if (vol > 127)vol = 127;
}
else if (currentButtonCode == Button3 && count == 0 && mute_pressed==0 && blokadaPilot==0)
{
vol = vol + 5;
if (vol > 127)vol = 127;
}
if (results.value == Button4 && count == 0 && mute_pressed==0 && blokadaPilot==1)
{
vol = vol - 0.5;
if (vol < 0)vol = 0;
}
else if (currentButtonCode == Button4 && count == 0 && mute_pressed==0 && blokadaPilot==0)
{
vol = vol - 5;
if (vol < 0)vol = 0;
}
}
irrecv.resume();
}
Button3;4 - code from Apple remote, up down key
count - work only when count 0 is set (must be)
mute_pressed - work only, when mute_pressed is 0 (must be)
blokadaPilot=0 - work only, when you holding key (increase/decrease vol by 5) - added because Im looking for solve problem
blokadaPilot=1 - work only, when you are pressing key (increase/decrease vol by 0.5) - added because Im looking for solve problem
unsigned long currentButtonCode;
unsigned long lastButtonCode;
Problem is: sometimes when Im pressing (not holding) up or down key , it should be decrease/increase by 0.5 , but its not. Sometimes its increase/decrease by 0,5+5 or 5. But when Im looking at same time when was increased/decreased wrong (0,5+5 or only 5) in arduino uno, which have Irdump v1 or v2 - it was nothing wrong. So I think that NEC protocol has bug in software/library.
When Im holding key - always is increase/decrease by 5 - so its work ok. I have never seen that it was increase/decrease by 0,5 + 5
When I had disabled function with holding key, only pressing key all works ok, always decrease/increase by 0.5
Why 2 functions - one for 0.5 , second for 5? I would like to increa/decrease when pressing by 0.5, when holding by 5 or 10 But I think that this future have bug?
Thanks and have a good day to all