#include <LiquidCrystal_I2C.h>
const int buzzer = 9;
LiquidCrystal_I2C lcd(0x27,16,2); /*I2C scanned address defined + I2C screen size*/
void setup() {
// put your setup code here, to run once:
pinMode(buzzer , OUTPUT);
lcd.init(); /*LCD display initialized*/
lcd.clear(); /*Clear LCD Display*/
lcd.backlight(); /*Turn ON LCD Backlight*/
lcd.setCursor(0,0); /*Set cursor to Row 1*/
lcd.print("I2C LCD Nano");
delay(1000);
lcd.clear();
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available() > 0)
{
String data = Serial.readStringUntil('\n');
if (data == "active")
{
tone(buzzer , 3000 , 1000);
Lcd_Show_Text();
}
else
{
noTone(buzzer);
}
}
}
void Lcd_Show_Text()
{
lcd.setCursor(0,0); /*Set cursor to Row 1*/
lcd.print("You are parking"); /*print text on LCD*/
lcd.setCursor(0,1);
lcd.print("in a private");
delay(3000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("parking, please");
lcd.setCursor(0,1);
lcd.print("move your car");
delay(3000);
lcd.clear();
}