#include <EEPROM.h>
int Kod = 0;
int Button_Power = -1;
int Button_Ch1 = -1;
int Button_Ch2 = -1;
int Button_Plus = EEPROM.read(1);
int Button_Minus = EEPROM.read(2);
#include <IRremote.h>
IRrecv ir_rx(2);
decode_results ir_rx_results;
unsigned long fnc_ir_rx_decode()
{
bool decoded=false;
if( ir_rx.decode(&ir_rx_results))
{
decoded=true;
ir_rx.resume();
}
if(decoded)
return ir_rx_results.value;
else
return 0;
}
void setup() {
ir_rx.enableIRIn();
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
}
void loop() {
Kod = (unsigned long)fnc_ir_rx_decode();
if (Kod == 17850) {
Button_Power = Button_Power * -1;
analogWrite(6, Button_Plus);
analogWrite(5, Button_Minus);
}
if (Kod == 3315) {
Button_Ch1 = Button_Ch1 * -1;
Button_Ch2 = -1;
}
if (Kod == 6375) {
Button_Ch2 = Button_Ch2 * -1;
Button_Ch1 = -1;
}
if (Button_Power == 1 & Button_Ch1 == 1) {
if (Kod == 16575) {
Button_Plus = Button_Plus + 15;
if (Button_Plus > 255) {
Button_Plus = 255;
}
EEPROM.write(1,Button_Plus);
delay(50);
}
if (Kod == 6630) {
Button_Plus = Button_Plus - 15;
if (Button_Plus < 0) {
Button_Plus = 0;
}
EEPROM.write(1,Button_Plus);
delay(50);
}
analogWrite(6, Button_Plus);
}
if (Button_Power == 1 & Button_Ch2 == 1) {
if (Kod == 16575) {
Button_Minus = Button_Minus + 15;
if (Button_Minus > 255) {
Button_Minus = 255;
}
EEPROM.write(2,Button_Minus);
delay(50);
}
if (Kod == 6630) {
Button_Minus = Button_Minus - 15;
if (Button_Minus < 0) {
Button_Minus = 0;
}
EEPROM.write(2,Button_Minus);
delay(50);
}
analogWrite(5, Button_Minus);
}
if (Button_Power == -1) {
pinMode(6, OUTPUT);
digitalWrite(6, 0);
pinMode(5, OUTPUT);
digitalWrite(5, 0);
}
}