// LCD1602 to Arduino Uno connection example
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
int i=0;
int a=10;
const int buzzer = 6; //buzzer to arduino pin 6
int value = A0;
int c1 = 500;
void setup() {
lcd.begin(16, 2); //setam numarul de coloane si de linii a displayului
pinMode(buzzer, OUTPUT); // Set buzzer - pin 6 as an output
Serial.begin(9600);
}
void loop() {
//Program potentiometru
int c2 = analogRead(value);
// Print out the value you read:
Serial.println(c2);
delay(1); // delay in between reads for stability
//Lcd program
lcd.begin(16, 2);//setam numarul de coloane si de linii a displayului
for(i=0;i<=16;i++){
lcd.setCursor( i , 1);
lcd.print("z");
};
for(i=16;i>=0;i--){
lcd.setCursor( i , 0 );
lcd.print(" ");
delay(a);
lcd.print("Hello");
delay(a);
lcd.print(" ");
delay(a);
}
//Buzzer program
if (c2>c1){
tone(buzzer, 1000); // Send 1KHz sound signal...
delay(5); // ...for 1 sec
noTone(buzzer); // Stop sound...
delay(5); // ...for 1sec
}
else {digitalWrite(buzzer, LOW);}
}