Advertisement
Guest User

Untitled

a guest
Nov 14th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. const int ButtonPin=4;
  2. int ReadValue;
  3. const int LEDred = 9;
  4. const int LEDgreen = 10;
  5. const int LEDblue = 11;
  6. int REDPIN= 9;
  7. int GREENPIN= 10;
  8. int BLUEPIN= 11;
  9. int Motion= 2;
  10. //YWROBOT
  11. //Compatible with the Arduino IDE 1.0
  12. //Library version:1.1
  13. #include <LiquidCrystal_I2C.h>
  14.  
  15. LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27
  16.  
  17. void setup() {
  18. // put your setup code here, to run once:
  19. Serial.begin(9600);
  20. pinMode (LEDred, OUTPUT);
  21. pinMode (LEDgreen, OUTPUT);
  22. pinMode (LEDred, OUTPUT);
  23. pinMode (ButtonPin, INPUT);
  24. lcd.init(); // initialize the lcd
  25. // Print a message to the LCD.
  26. lcd.backlight();
  27. lcd.setCursor(3,0);
  28. lcd.print("Hello, world!");
  29. lcd.setCursor(2,1);
  30. lcd.print("Ywrobot Arduino!");
  31. lcd.setCursor(6,6);
  32. lcd.clear();
  33. lcd.print("Abby's");
  34. lcd.setCursor(5,6);
  35. lcd.print("Lamp");
  36. pinMode (REDPIN, OUTPUT);
  37. pinMode (GREENPIN, OUTPUT);
  38. pinMode (BLUEPIN, OUTPUT);
  39. pinMode (Motion, INPUT);
  40. for (int i=0; i<10; i++)
  41. {
  42. analogWrite (REDPIN, 0);
  43. analogWrite (GREENPIN, 0);
  44. analogWrite (BLUEPIN, 0);
  45. delay (100);
  46. analogWrite (REDPIN, 255);
  47. analogWrite (GREENPIN, 100);
  48. analogWrite (BLUEPIN, 155);
  49. delay (100);
  50. }
  51.  
  52.  
  53. void loop()
  54.  
  55. {
  56. {
  57.  
  58. Serial.println(ReadValue);
  59. ReadValue= digitalRead (ButtonPin);
  60. analogWrite(LEDred, 255);
  61. analogWrite(LEDgreen, 100);
  62. analogWrite(LEDblue, 155);
  63. delay (1000);
  64. analogWrite(LEDred, 142);
  65. analogWrite(LEDgreen, 235);
  66. analogWrite(LEDblue, 216);
  67. delay(1000);
  68. analogWrite(LEDred, 246);
  69. analogWrite(LEDgreen, 10);
  70. analogWrite(LEDblue, 255);
  71. delay(1000);
  72. analogWrite(LEDred, 42);
  73. analogWrite(LEDgreen, 248);
  74. analogWrite(LEDblue, 192);
  75. delay(1000);
  76. }
  77. if (digitalRead (Motion) == HIGH)
  78. {
  79. analogWrite (REDPIN, 255);
  80. analogWrite (GREENPIN, 100);
  81. analogWrite (BLUEPIN, 155);
  82. delay (100);
  83. }
  84. else
  85. {
  86. analogWrite (REDPIN, 0);
  87. analogWrite (GREENPIN, 0);
  88. analogWrite (BLUEPIN, 0);
  89. }
  90.  
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement