Advertisement
noob-code-bunny

Test sketch for Arduino Controlled Pc Power Switch

Jun 10th, 2018
639
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <IRremote.h>
  2. const int RECV_PIN = 4;
  3. const int redPin = 13;
  4. // Define IR Receiver and Results Objects
  5. IRrecv irrecv(RECV_PIN);//irrecv is the receiver object, you can use whatever name you want
  6. decode_results results;
  7.  
  8. int buttonState = 0;
  9. int togglestate = 0;
  10.  
  11.  
  12. int incomingByte;  
  13. int state = HIGH;
  14. int reading;
  15. int previous = LOW;
  16.  
  17. void setup()
  18. {
  19.   Serial.begin(9600);
  20.   irrecv.enableIRIn(); // Start the receiver
  21.   pinMode(redPin, OUTPUT);
  22. }
  23. void loop(){
  24.   if (irrecv.decode(&results)) {// irrecv.decode(&results) :Returns true if a code was receive
  25.     Serial.println(results.value, HEX);
  26.     if(results.value==0xFF28D7){
  27.       digialWrite(redPin, LOW);
  28.       delay(500);
  29.       digitalWrite(redPin, HIGH);
  30.      }
  31.      delay(300);// this delay is here to avoid the 0xFFFFFFF
  32.      irrecv.resume (); // Receive the next value
  33.    }
  34.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement