I have been trying to combine a light code with this tone keyboard so that when the button is pressed, sound and light are produced. A different LED for the different buttons. this is the code i have now, and its just for the tone KB, please how to i combine the LED section to this?
/*
Keyboard
Plays a pitch that changes based on a changing
input circuit:
3 pushbuttons from +5V to analog in 0 through
3
3 10K resistors from analog in 0 through 3 to
ground
void loop()
{
// if button press on A0 is detected
if (digitalRead(A0) == HIGH) {
tone(8, 440, 100); // play tone 57 (A4 = 440 Hz)
}
// if button press on A1 is detected
if (digitalRead(A1) == HIGH) {
tone(8, 494, 100); // play tone 59 (B4 = 494 Hz)
}
// if button press on A0 is detected
if (digitalRead(A2) == HIGH) {
tone(8, 523, 100); // play tone 60 (C5 = 523 Hz)
}
delay(10); // Delay a little bit to improve simulation performance
}
PaulS:
Of course, with those useless delay()s, make sure you press the switch long enough.
Small steps Paul.
You may want to jump in and solve all of the problems at once but I don't think the OP is ready for that. I am sure that we can see plenty of problems coming down the line if delay() is used but let's deal with them as they arise.
You may want to jump in and solve all of the problems at once but I don't think the OP is ready for that. I am sure that we can see plenty of problems coming down the line if delay() is used but let's deal with them as they arise.
I totally agree. I just want OP to be aware of the fact that the direction he is moving while painting the floor is not the direction where the door is.