Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <IRremote.h>
- const int receiver = 5;
- IRrecv irrecv(receiver);
- decode_results results;
- const byte releuPin = 6;
- volatile byte stat = 0;
- const int buzzerPin = 4;
- void setup()
- { irrecv.enableIRIn();
- pinMode(releuPin, OUTPUT);
- pinMode(buzzerPin, OUTPUT);
- }
- void playTone(int tone, int duration) {
- for (long i = 0; i < duration * 1000L; i += tone * 2) {
- digitalWrite(buzzerPin, HIGH);
- delayMicroseconds(tone);
- digitalWrite(buzzerPin, LOW);
- delayMicroseconds(tone);
- }
- }
- void loop() {
- if (stat) {
- digitalWrite(releuPin, HIGH);
- delay(1000);
- digitalWrite(releuPin, LOW);
- delay(1000);
- }
- if (irrecv.decode(&results))
- {
- if (results.value == 0x20DF807F)
- digitalWrite(releuPin, HIGH);
- else
- if(results.value == 0x20DF609F)
- playTone(2000, 500);
- else
- if(results.value == 0x20DF906F)
- digitalWrite(releuPin, LOW);
- else
- if(results.value == 0x20DF50AF)
- {
- digitalWrite(releuPin, HIGH);
- playTone(2000, 500);
- }
- else if(results.value == 0x20DFD02F)
- {
- digitalWrite(releuPin, LOW);
- playTone(2000, 500);
- }
- irrecv.resume(); // receive the next value
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment