Avete bisogno di:
1x LCD Hitachi HD44780
2x Bottoni
Dopo aver montato l'LCD, bottoni e aver effettuato i collegamenti uploadate lo sketch in Arduino.
Dopodichè seguite le istruzioni sul Display.
Funzioni:
Primo bottone: Aumenta il valore
Secondo bottone: Sceglie tra Ore,Minuti e conferma.
#include <LiquidCrystal.h>
#include <Button.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Button buttonadd = Button(6,PULLDOWN);
Button buttonconf = Button(7,PULLDOWN);
int h = 0;
int m = 0;
int s = 0;
int step = 0;
void setup() {
lcd.begin(16, 2);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
lcd.print("Imposta l'ora");
makestring();
}
void loop() {
if (buttonadd.uniquePress()){
if (step ==0){
if (h == 23)
{
h=0;
}
else
{
h++;
}
lcd.clear();
lcd.print("Imposta l'ora");
makestring();
}
if (step ==1){
if (m == 59)
{
m=0;
}
else
{
m++;
}
lcd.clear();
lcd.print("Imposta i min");
makestring();
}
}
if (buttonconf.uniquePress()){
if (step ==1){
step++;
}
if (step ==0){
step++;
lcd.clear();
lcd.print("Imposta i min");
makestring();
}
}
if (step == 2)
{
startTimeEngine();
}
}
void startTimeEngine() {
lcd.clear();
lcd.print("Orologio");
if (s == 59){
m++;
s = 0;
}
else
{
s++;
}
if (m == 60){
h+=1;
m = 0;
}
if (h == 24){
h=0;
}
makestring();
delay(1000);
}
void makestring() {
lcd.setCursor(0,1);
if (h<10){
lcd.print("0");
lcd.print(h);
}
else
{
lcd.print(h);
}
lcd.print(":");
if (m<10){
lcd.print("0");
lcd.print(m);
}
else
{
lcd.print(m);
}
lcd.print(":");
if (s<10){
lcd.print("0");
lcd.print(s);
}
else
{
lcd.print(s);
}
}
vi sono degli errori nelle righe 6-7-24-55
ReplyDeletevi sono degli errori nelle righe 6-7-24-55
ReplyDelete