I'm an Arduino beginner and I want to write a little program that plays notes when I press a button (also prompts to press button on lcd).
To make the notes play, I want to write a little function that plays the note on the piezo and has a delay, but when I try to upload the code, this error appears:
Can somebody help me? Here's my code:
#include <LiquidCrystal.h>
int VO = 2;
int RS = 3;
int E = 4;
int D4 = 8;
int D5 = 9;
int D6 = 10;
int D7 = 11;
int PIEZO = 12;
int BUTTON = A0;
LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
void setup() {
pinMode(BUTTON, INPUT_PULLUP);
analogWrite(VO, 0);
lcd.begin(16, 2);
lcd.print("Press the button");
}
void playTone(a, b) {
c = b * 800;
tone(PIEZO, a, c);
delay(c);
}
void loop() {
if (analogRead(BUTTON) == 1023) {
playTone(255, 1);
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…