Instructables

How to get a arduino to use 3push buttons as inputs, and output a different signal on a speaker

Hey all,
 I am new to the whole arduino using world.  I have a project that uses 3push buttons, a  breadboard, arduino, lcd display, and speaker.
The goal is to write program to play a certain freq. signal through the speaker, (each pushbutton has it's own frequency for the signal) when each of the buttons is pushed, and also display each signal on  the LCD display while doing it.

Have you looked at similar projects?

These are a little more complicated then what you already have but will give you some ideas about how to go about achieving your goal. This first one will give you some ideas about the buttons and the sounds.
http://www.instructables.com/id/Arduino-Simon-Says/

This next one takes things a bit further adding an LCD to the mix and some more options. 
http://www.instructables.com/id/Total-Recall-Arduino-Simon-Says-on-steroids/
dsm5286 (author)  mpilchfamily1 year ago
I got it figured out. Thanks for help. I started over from scratch and made each button it's own const int and each it's own button state, added in the LCD pin at Tx, and added the sub routines, and after few hours of fixing little typo's got it to work. Again thanks for the help.
Start simple: Use the examples in the Arduino IDE and make sure they work the bits you have. Learn how to read buttons, learn how to write to the LCD, learn how to make tones. Once you can do that, the code for the thing is very simple.

Steve
dsm5286 (author)  steveastrouk1 year ago
I have some code written. for setting up the buttons. The first two work, but the last one doesn't, and it just keeps playing one tone even if none are pressed...and I have the part down to write to the lcd.. I've made simple tones, but it keeps telling me I didn't define pitches.h in my program in one window, but if i copy and paste it to another blank page, it does what I described earlier in this reply.
Post your code. Do you have pull up resistors on your buttons, or pull downs ? "pitches.h" implies you are using a library. Where's it from ?
dsm5286 (author)  steveastrouk1 year ago
#include "pitches.h"


const int button = 0; // the number of the pushbutton pin
int buttonState = 0; // variable for reading the pushbutton status
// notes to play, corresponding to the 3 sensors:

int notes[] = {
NOTE_A3, NOTE_B4, NOTE_C3};

void setup() {
pinMode(button, INPUT);
// initialize the pushbutton pin as an input
}

void loop() {
for (int button = 0; button < 3; button++) {
// get a sensor reading:
int buttonState = digitalRead(button);

// if the sensor is pressed hard enough:
if (buttonState == HIGH) {
// play the note corresponding to this sensor:
tone(8, notes[button]);
}
}
}
here is the code so far. and once i get it to work properly by addin a no tone when digitalread=0 then i will move the button pins to 2-4 and add LCD code.
But you only have ONE button defined in the setup, and that is digital Pin 0.