Hi everyone!
I'm a pretty new user of Arduino and I'm working on a clock and alarm project.
I'm using the Arduino UNO starter kit and the 2x16 LCD screen found in there.
My problem is that whenever the piezo starts ringing, the LCD display start showing white blocks and/or random characters.
Executing the code without calling the function alarmBeep() result in the LCD screen functioning perfectly, therefore I think that the problem is not in the electronics themselves. The code should also work fine, so I'm quite lost...
My conclusion is that in some way the signal sent to the piezo interferes with those sent to the LCD but it's not clear to me why this happens...
Here is the code I'm using.
#include <LiquidCrystal.h>
LiquidCrystal lcd(A5, A4, A3, A2, A1, A0);
#define BUZZER 9
int i;
void setup() {
pinMode(BUZZER, OUTPUT);
// Setup LCD
lcd.begin(16, 2);
lcd.noAutoscroll();
lcd.display();
}
void loop() {
checkprint();
delay(150);
}
void checkprint(){
i = 0;
int ItoPrint[] = {1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8};
char CtoPrint[] = {"abcdefghilmnopqr"};
lcd.setCursor(0, 0);
while(i<16){
lcd.print(ItoPrint[i]);
delay(200);
i++;
}
alarmBeep();
i=0;
lcd.setCursor(0, 1);
while(i<16){
lcd.print(CtoPrint[i]);
delay(200);
i++;
}
}
void alarmBeep() {
tone(BUZZER, 2000);
delay(200);
noTone(BUZZER);
}
Here is the electronics diagram.
As I'm a new user I unfortunately cannot add more pictures.


