|
-TOPSHIRIQ
Simsiz aloqa tarmoqlari orqali ma’lumotlarni uzatish va boshqarish
|
səhifə | 3/3 | tarix | 22.12.2023 | ölçüsü | 131,27 Kb. | | #189599 |
| 3-topshiriq
Kodi:
#include
int voltage[12];
unsigned int i = 0;
IRrecv irrecv(12);
decode_results results;
unsigned long key_value = 0;
void setup()
{
Serial.begin(9600);
SetUpPins();
irrecv.enableIRIn();
irrecv.blink13(true);
pinMode(13, OUTPUT);
}
void loop()
{
TranslateIR();
}
void ToggleLED(int pin){
if(voltage[pin]){
Serial.print("LED");
Serial.print(pin-2);
Serial.println("was turned off");
digitalWrite(pin,LOW);
voltage[pin] = 0;}
else{
Serial.print("LED");
Serial.print(pin-2);
Serial.println("was turned on");
digitalWrite(pin,HIGH);
voltage[pin] = 1;}
}
void SetUpPins(){
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,LOW);}
void TranslateIR(){
if(irrecv.decode(&results)){
if(results.value == 0XFFFFFFFF)
results.value = key_value;
switch(results.value){
case 0XFD00FF:
break;
case 0XFD807F:
break;
case 0XFD40BF:
break;
case 0XFD20DF:
break;
case 0XFDA05F:
break;
case 0XFD609F:
break;
case 0XFD10EF:
break;
case 0XFD906F:
break;
case 0XFD50AF:
break;
case 0XFD30CF:
ToggleLED(2);
break;
case 0XFDB04F:
break;
case 0XFD708F:
break;
case 0XFD08F7:
ToggleLED(3);
break;
case 0XFD8877:
ToggleLED(4);
break;
case 0XFD48B7:
ToggleLED(5);
break;
case 0XFD28D7:
ToggleLED(6);
break;
case 0XFDA857:
ToggleLED(7);
break;
case 0XFD6897:
ToggleLED(8);
break;
case 0XFD18E7:
ToggleLED(9);
break;
case 0XFD9867:
ToggleLED(10);
break;
case 0XFD58A7:
ToggleLED(11);
break;
}
key_value = results.value;
irrecv.resume();
}
pinMode(LED_BUILTIN, OUTPUT
Dostları ilə paylaş: |
|
|