Mouamle

Arduino Code bit

Jun 11th, 2016
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <IRremote.h>
  2.  
  3. int RECV_PIN = 3;
  4. int RELAY_PIN = 13;
  5.  
  6. IRrecv irrecv(RECV_PIN);
  7. decode_results results;
  8.  
  9. int An = 0;
  10. bool debug = false;
  11.  
  12. void setup(){
  13.   pinMode(RELAY_PIN, OUTPUT);
  14.   pinMode(13, OUTPUT);
  15.   pinMode(10, OUTPUT);
  16.   pinMode(7, OUTPUT);
  17.   Serial.begin(9600);
  18.   irrecv.enableIRIn(); // Start the receiver
  19. }
  20.  
  21. void loop() {
  22.   if (irrecv.decode(&results)) {
  23.     long value = results.value;
  24.     Serial.println(value, HEX);
  25.     irrecv.resume(); // Receive the next value
  26.   }
  27.  
  28.   if ( Serial.available() > 0 ){
  29.     int state = Serial.read();
  30.  
  31.     if ( state == 1 ){
  32.       blink(13, 100);
  33.     }else if ( state == 2 ){
  34.       blink(7, 100);
  35.     }else if ( state == 10 ){
  36.       blink(10, 1000);
  37.     }
  38.   }
  39.  
  40. }
  41.  
  42. void blink(int pin, long timeout){
  43.   digitalWrite(pin, HIGH);
  44.   delay(timeout);
  45.   digitalWrite(pin, LOW);
  46. }
Add Comment
Please, Sign In to add comment