#include <IRremote.h>
int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;
#define CH1 0xFFA25D
#define CH 0xFF629D
#define CH2 0xFFE21D
#define PREV 0xFF22DD
#define NEXT 0xFF02FD
#define PLAYPAUSE 0xFFC23D
#define VOL1 0xFFE01F
#define VOL2 0xFFA857
#define EQ 0xFF906F
#define BUTON0 0xFF6897
#define BUTON100 0xFF9867
#define BUTON200 0xFFB04F
#define BUTON1 0xFF30CF
#define BUTON2 0xFF18E7
#define BUTON3 0xFF7A85
#define BUTON4 0xFF10EF
#define BUTON5 0xFF38C7
#define BUTON6 0xFF5AA5
#define BUTON7 0xFF42BD
#define BUTON8 0xFF4AB5
#define BUTON9 0xFF52AD
int ledler[]= {3,4,5,6,7,8,9,10};
int led1 = 3;// KIRMIZI
int led2 = 4;//YESİL
int led3 = 5;//MAVİ
int led4 = 6;//RGB
int led5 = 7;//KIRMIZI
int led6 = 8;//YESİL
int led7 = 9;//MAVİ
int led8 = 10;//RGB;
int k;
int i;
int j;
void setup()
{
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led7, OUTPUT);
pinMode(led8, OUTPUT);
Serial.begin(9600);
irrecv.enableIRIn();
}
void loop() {
if (irrecv.decode(&results))
{
if (results.value == CH1)
{
digitalWrite(led1, !digitalRead(led1));
digitalWrite(led5, !digitalRead(led5));
}
if (results.value == CH)
{
digitalWrite(led2, !digitalRead(led2));
digitalWrite(led6, !digitalRead(led6));
}
if (results.value == CH2)
{
digitalWrite(led3, !digitalRead(led3));
digitalWrite(led7, !digitalRead(led7));
}
if (results.value == PREV)
{
digitalWrite(led4, !digitalRead(led4));
digitalWrite(led8, !digitalRead(led8));
}
if (results.value == NEXT)
{
for(int i=0; i<8; i++) {
digitalWrite(ledler, HIGH);
delay(20);
digitalWrite(ledler, LOW);
} //İlk ledden beşinci lede kadar ledler sırasıyla yanıyor. Yani döngüde ilk led yanar, söner ve ikinci led yanar. İkinci led söndüğünde ise üçüncü led yanar ve döngü bu şekilde devam eder.
for(int j=7; j>-1; j--) {
digitalWrite(ledler[j], HIGH);
delay(20);
digitalWrite(ledler[j], LOW);
}
if (results.value == VOL1)
{
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led5, HIGH);
digitalWrite(led6, HIGH);
digitalWrite(led7, HIGH);
digitalWrite(led8, HIGH);
}
if (results.value == PLAYPAUSE)
{
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
irrecv.resume();
}
}