Guest User

Untitled

a guest
Feb 15th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. /*
  2. IRremote: modified from IRrecvDemo - demonstrates receiving IR codes with IRrecv
  3. and decodes specific messages
  4. An IR detector/demodulator must be connected to the input RECV_PIN.
  5. */
  6.  
  7. // UP 1FE10EF
  8. // DOWN 1FED827
  9.  
  10. #include <IRremote.h>
  11.  
  12. // the receiver should be connected to this pin
  13. int RECV_PIN = 11;
  14.  
  15. // delcare and initialize IRrecv object
  16. IRrecv irrecv(RECV_PIN);
  17. // decode_results object
  18. decode_results results;
  19.  
  20. int ledPin = 9;
  21. int ledpin2 = 4;
  22. int bright = 50;
  23.  
  24. void setup()
  25. {
  26. Serial.begin(9600);
  27. // In case the interrupt driver crashes on setup, give a clue
  28. // to the user what's going on.
  29. Serial.println("Enabling IRin");
  30. irrecv.enableIRIn(); // Start the receiver
  31. Serial.println("Enabled IRin");
  32. //
  33. // output to toggle on/off with receieved and decoded messages
  34. pinMode(ledPin, OUTPUT);
  35. pinMode (ledpin2, OUTPUT);
  36. }
  37.  
  38. void loop() {
  39. digitalWrite(ledpin2, HIGH);
  40. analogWrite(ledPin,bright);
  41. if (irrecv.decode(&results)) {
  42. // print the value received and decoded
  43. Serial.println(results.value, HEX);
  44.  
  45. //if the button press equals the hex value 0x....
  46. if (results.value == 0x1FE10EF)
  47. {
  48. bright = bright + 20;
  49. Serial.println("increase brightness");
  50.  
  51. }
  52. else if (results.value == 0x1FED827)
  53. {
  54. bright = bright - 20;
  55. Serial.println("decrease brightness");
  56.  
  57.  
  58. }
  59.  
  60. Serial.println(bright);
  61.  
  62.  
  63. irrecv.resume(); // Receive the next value
  64. }
  65. delay(100);
  66. }
Add Comment
Please, Sign In to add comment