so my wiring is all correct, but my code is off somehow, and im wondering if y'all know why
I got example code from the internet, and it worked with my wiring, so the wiring isn't the problem
the example code works for a little three button piano, declaring and using real notes instead of the frequency values I learned to use in the arduino "tone" function
but my own code, which I will post below, won't work properly
I would love to know why
I got example code from the internet, and it worked with my wiring, so the wiring isn't the problem
the example code works for a little three button piano, declaring and using real notes instead of the frequency values I learned to use in the arduino "tone" function
but my own code, which I will post below, won't work properly
I would love to know why
MY (not working) version of the three note piano:
const int buzzPin = 11;
const int buttonOne = 10;
const int buttonTwo = 9;
const int buttonThree = 8;
void setup()
{
pinMode (buzzPin, OUTPUT);
pinMode (buttonOne, INPUT);
pinMode (buttonTwo, INPUT);
pinMode (buttonThree, INPUT);
noTone (11);
}
void loop() {
while (digitalRead (buttonOne == HIGH))
{
tone (11, 100);
}
while (digitalRead (buttonOne == LOW))
{
noTone (11);
}
while (digitalRead (buttonTwo == HIGH))
{
tone (11, 500);
}
while (digitalRead (buttonTwo == LOW))
{
noTone (11);
}
while (digitalRead (buttonThree == HIGH))
{
tone (11, 1000);
}
while (digitalRead (buttonThree == LOW))
{
noTone (11);
}
}