Now I have added VOL+ and VOL-. Adding is good, but it doesnt work correctly. Sometimes when I click "VOL+" on remote I have added 2-3, not 1,1,1,1,1,1.
// rotary encoder demo by 'jurs' for Arduino Forum
// This is the code for the main "sketch"
#include <IRremote.h>
#define irPin 8 // pin dla TSOP
IRrecv irrecv(irPin);
decode_results results;
#include "encoder.h"
#define BAUDRATE 115200L // serial baud rate
#define LEDPin 12 //up
void setup() {
irrecv.enableIRIn();
Serial.begin(BAUDRATE);
Serial.println();
Serial.println("Good night and good luck!"); // print some Test-Message at beginning
beginEncoders();
pinMode(LEDPin, OUTPUT);
}
void printEncoders()
{ // print current count of each encoder to Serial
for (int i=0; i<NUMENCODERS; i++)
{
Serial.print(encoder[i].count);
Serial.print('\t');
}
Serial.println();
}
void loop()
{
if (encoder[0].count == 1)
{
digitalWrite(LEDPin, HIGH);
}
if (encoder[0].count == 0)
{
digitalWrite(LEDPin, LOW);
}
if (irrecv.decode(&results))
{
switch (results.value)
{
case 0x801: // 1
digitalWrite(LEDPin, LOW);
break;
case 0x1: // 1
digitalWrite(LEDPin, HIGH);
break;
case 0x810: // VOL+
encoder[0].count ++;
break;
case 0x10: // VOL+
encoder[0].count ++;
break;
case 0x811: // VOL-
encoder[0].count --;
break;
case 0x11: // VOL-
encoder[0].count --;
break;
}
irrecv.resume();
}
if (updateEncoders()) printEncoders();
}
I have question. How can I update in serial monitor count when I press VOL+/VOL-? It doesnt count when I press VOL+/- , I must turn encoder to update status in serial monitor.