Ciao a tutti.
Sto facendo fatica a capire dove sto sbagliando nella programmazione, di un LCD quello che viene fornito con i kit arduino con una logica if else. Ogni volta che cambio lo statto della costante la scrittura sull LCD non cambia. Sotto il codice
//Digital PIN 11 A-E Enable LCD
//Digital PIN 12 A - RS LCD
//PIN R/W LCD- OV Write on LCD
//Digital PIN4 - DBO LCD
//Digital PIN4 - DB1 LCD
//Digital PIN4 - DB2 LCD
//Digital PIN4 - DB3 LCD
//Digital PIN4 2 - DB4 LCD
//Digital PIN4 3 - DB5 LCD
//Digital PIN4 4 - DB6 LCD
//Digital PIN4 5 - DB7 LCD
#include <LiquidCrystal.h>
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
//const int rs = 3, en = 2, d0 = , d1 = , d2 = , d3 = ,d4 = 2, d5 = 3, d6 = 4, d7 = 5;
//LiquidCrystal lcd(rs, en, d0, d1, d2, d3, d4, d5, d6, d7);
LiquidCrystal lcd(12,11,5,4,3,2);
const int SwitchPin=13;
int SwitchState;
void setup() {
Serial.begin (9600);
// const int SwitchPin=13;
// int SwitchState=0;
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
//lcd.print("");
pinMode (SwitchPin, INPUT);
SwitchState = digitalRead(SwitchPin);
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
//lcd.setCursor(0, 1);
// print the number of seconds since reset:
//pinMode (SwitchPin, INPUT);
//SwitchState = digitalRead(SwitchPin);
if (SwitchState==HIGH)
{
lcd.setCursor(0,0);
lcd.print("Che famo?");
lcd.setCursor(0,1);
lcd.print("Anammo?");
}
else //(SwitchState==LOW)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Ndo vammo?");
lcd.setCursor(0, 1);
lcd.print("Ndo stammo?");
}
Serial.print (SwitchState);
delay(5000);
return;
}
Se qualcuno ha qualche consiglio da darmi, grazie