#include <IRremote.h>
int RECV_PIN = 11; //
int output1 = 10;
int output2 = 6;
int output3 = 7;
int output4 = 8;
int itsONled[] = {0,0,0,0,0,0};
#define code1 0xE17AC23D //
#define code2 0xE17A40BF //
#define code4 0xA32AC03F //
#define code3 0xE17A20DF //
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
Serial.begin(9600); //
irrecv.enableIRIn(); //
pinMode(output1, OUTPUT);
pinMode(output2, OUTPUT);
pinMode(output3, OUTPUT);
pinMode(output4, OUTPUT);
}
void loop() {
if (irrecv.decode(&results)) {
unsigned int value = results.value;
switch(value) {
case code1:
if(itsONled[1] == 1) {
digitalWrite(output1, LOW);
itsONled[1] = 0; } else {
digitalWrite(output1, HIGH);
itsONled[1] = 1;
}
break;
case code2:
if(itsONled[2] == 1) {
digitalWrite(output2, LOW);
itsONled[2] = 0; } else {
digitalWrite(output2, HIGH);
itsONled[2] = 1;
}
break;
case code3:
if(itsONled[3] == 1) {
digitalWrite(output3, LOW);
itsONled[3] = 0; } else {
digitalWrite(output3, HIGH);
itsONled[3] = 1;
}
break;
case code4:
if(itsONled[4] == 1) {
digitalWrite(output4, LOW);
itsONled[4] = 0; } else {
digitalWrite(output4, HIGH);
itsONled[4] = 1;
}
break;
}
Serial.println(value); // you can comment this line
irrecv.resume(); // Receive the next value
}
}
sterowanie zpilota 4 kanały nowy #4
Re: sterowanie zpilota 4 kanały nowy #4
Działa extra. Teraz można za pomocą pilota od telewizora rozbudować funkcje sterowania poszczególnych urządzeń .
Kawał dobrej roboty.
Kawał dobrej roboty.