Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int ButtonPin=4;
- int ReadValue;
- const int LEDred = 9;
- const int LEDgreen = 10;
- const int LEDblue = 11;
- int REDPIN= 9;
- int GREENPIN= 10;
- int BLUEPIN= 11;
- int Motion= 2;
- //YWROBOT
- //Compatible with the Arduino IDE 1.0
- //Library version:1.1
- #include <LiquidCrystal_I2C.h>
- LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(9600);
- pinMode (LEDred, OUTPUT);
- pinMode (LEDgreen, OUTPUT);
- pinMode (LEDred, OUTPUT);
- pinMode (ButtonPin, INPUT);
- lcd.init(); // initialize the lcd
- // Print a message to the LCD.
- lcd.backlight();
- lcd.setCursor(3,0);
- lcd.print("Hello, world!");
- lcd.setCursor(2,1);
- lcd.print("Ywrobot Arduino!");
- lcd.setCursor(6,6);
- lcd.clear();
- lcd.print("Abby's");
- lcd.setCursor(5,6);
- lcd.print("Lamp");
- pinMode (REDPIN, OUTPUT);
- pinMode (GREENPIN, OUTPUT);
- pinMode (BLUEPIN, OUTPUT);
- pinMode (Motion, INPUT);
- for (int i=0; i<10; i++)
- {
- analogWrite (REDPIN, 0);
- analogWrite (GREENPIN, 0);
- analogWrite (BLUEPIN, 0);
- delay (100);
- analogWrite (REDPIN, 255);
- analogWrite (GREENPIN, 100);
- analogWrite (BLUEPIN, 155);
- delay (100);
- }
- void loop()
- {
- {
- Serial.println(ReadValue);
- ReadValue= digitalRead (ButtonPin);
- analogWrite(LEDred, 255);
- analogWrite(LEDgreen, 100);
- analogWrite(LEDblue, 155);
- delay (1000);
- analogWrite(LEDred, 142);
- analogWrite(LEDgreen, 235);
- analogWrite(LEDblue, 216);
- delay(1000);
- analogWrite(LEDred, 246);
- analogWrite(LEDgreen, 10);
- analogWrite(LEDblue, 255);
- delay(1000);
- analogWrite(LEDred, 42);
- analogWrite(LEDgreen, 248);
- analogWrite(LEDblue, 192);
- delay(1000);
- }
- if (digitalRead (Motion) == HIGH)
- {
- analogWrite (REDPIN, 255);
- analogWrite (GREENPIN, 100);
- analogWrite (BLUEPIN, 155);
- delay (100);
- }
- else
- {
- analogWrite (REDPIN, 0);
- analogWrite (GREENPIN, 0);
- analogWrite (BLUEPIN, 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement