safwan092

Untitled

Nov 27th, 2018
179
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int red = 3;
  2. int green = 9;
  3. int blue = 10;
  4. #include <IRremote.h>
  5.  
  6. int RECV_PIN = 11;
  7. IRrecv irrecv(RECV_PIN);
  8. decode_results results;
  9. int redBrightness = 0;
  10. int greenBrightness = 0;
  11. int blueBrightness = 0;
  12. void setup() {
  13.  
  14.  
  15. Serial.begin(9600);
  16. Serial.println("Enabling IRin");
  17. irrecv.enableIRIn(); // Start the receiver
  18. Serial.println("Enabled IRin");//initialising serial monitor
  19.  
  20. /***Pin mode declaration***/
  21. pinMode(red, OUTPUT);
  22. pinMode(green, OUTPUT);
  23. pinMode(blue, OUTPUT);
  24.  
  25. }
  26.  
  27. void loop() {
  28. if (irrecv.decode(&results)) {
  29. Serial.println(results.value, HEX);
  30.  
  31. switch (results.value) {
  32.  
  33. case 0xE318261B:
  34. setcolor (255, 0, 0);
  35. break;
  36. case 0x511DBB:
  37. setcolor (0, 255, 0);
  38. break;
  39. case 0xFFE21D:
  40. setcolor (0, 0, 255);
  41. break;
  42. default:
  43. break;
  44. }
  45. irrecv.resume(); // Receive the next value
  46. }
  47. delay(100);
  48.  
  49. }
  50.  
  51. void setcolor (int red, int green, int blue) {
  52. int red1 = 255 - red ;
  53. int green1 = 255 - green;
  54. int blue1 = 255 - blue;
  55. analogWrite(red1, redBrightness);
  56. analogWrite(green1, greenBrightness);
  57. analogWrite(blue1, blueBrightness);
  58. delay(3000);
  59. }
RAW Paste Data