I'm working on this piano project. When I push a button one of the led light is suppose to turn on and a tone comes out of the piezo. The LCD screen is suppose to print out a sentence but I can't get it to work.
Here is a picture of the board ( everything works except the LCD) I think the problems lies in the power supply but I'm not sure. This is the first time I use a big breadboard.
Here is my code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(13,12,11,10,9,8);
int p1 = 1;
int p2 = 2;
int p3 = 3;
int p4 = 4;
int C,D,E,F;
int buzz = 5;
void setup()
{
lcd.begin(16, 2);
lcd.print("hello, world!");
Serial.begin(9600);
pinMode(p1,INPUT);
pinMode(p2,INPUT);
pinMode(p3,INPUT);
pinMode(p4,INPUT);
}
void loop()
{
lcd.setCursor(0, 1);
lcd.print(millis() / 1000);
C = digitalRead(p1);
D = digitalRead(p2);
E = digitalRead(p3);
F = digitalRead(p4);
if(C == 1){
tone(buzz,523);
}else if(D == 1){
tone(buzz,587);
}else if(E == 1){
tone(buzz,659);
}else if(F == 1){
tone(buzz,698);
}else{
noTone(buzz);
}
delay(50);
}