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. Image of the board
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);
}
-
3the power rails are separated in the middle of the breadboard. bridge them with jumper wiresJuraj– Juraj ♦2019年04月17日 13:57:52 +00:00Commented Apr 17, 2019 at 13:57
-
1According to the picture, RS and E are connected to pin 8 and 9. According to your sketch, RS and E are connected to 13 and 12.Jot– Jot2019年04月17日 15:42:45 +00:00Commented Apr 17, 2019 at 15:42
-
Did you set the contrast correctly (using the potentiometer)?Gerben– Gerben2019年04月18日 08:58:02 +00:00Commented Apr 18, 2019 at 8:58
2 Answers 2
The LCD is not powered, there are 2 separated power rails... use a wire to connect both rails.
-
-
You need to use a wire to connect the 2 rails. Right where is the bigger separation.Rene Ramirez– Rene Ramirez2019年04月17日 19:22:41 +00:00Commented Apr 17, 2019 at 19:22
the power rails are separated in the middle of the breadboard. bridge them with jumper wires