Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h>
- #include <Servo.h>
- Servo myservo; // create servo object to control a servo
- LiquidCrystal_I2C lcd(0x27, 16, 2);
- const int buzzer = 13;
- int x = 0;
- // the setup routine runs once when you press reset:
- void setup() {
- // initialize serial communication at 9600 bits per second:
- Serial.begin(9000);
- pinMode(buzzer, OUTPUT);
- myservo.attach(9);
- myservo.write(90);
- // lcd.begin();
- lcd.init ();
- lcd.backlight();
- }
- // the loop routine runs over and over again forever:
- void loop() {
- // read the input on analog pin 0:
- int sensorValue = analogRead(A0);
- // print out the value you read:
- Serial.println(sensorValue);
- if (sensorValue < 500) {
- if (sensorValue < 500) {
- lcd.clear();
- lcd.print("Its raining");
- lcd.setCursor (0, 1);
- myservo.write(0);
- delay(10000);
- }
- digitalWrite(buzzer, HIGH);
- } else {
- lcd.clear();
- myservo.write(90);
- digitalWrite(buzzer, LOW);
- }
- delay(20); // delay in between reads for stability
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement