Which sensor/button would be best?

Thanks for reading my first post!

I am fairly brand new to the Arduino and electronics in general but I have some really cool ideas that I am trying to make a reality, I am just lacking a lot of background knowledge. Here's my issue:

I have a project involving a photoresistor and I was attempting to use pushbuttons as well but I don't know if what I am trying to do is feasible with them. I want an event to trigger when the photoresistor drops below a certain value. However; I want that event to change depending on which button I am pressing at the time and only when that button is being pressed.

I bought some normally open momentary pushbutton switches but they don't have any output (that I am aware of at least) and the regular 6mm pushbuttons seem to switch between on and off. I tried using code to reset the buttons state but I need it to stay on for variable lengths of time. Is there some better hardware I should consider trying to use?

Thanks again!

braveneuroworlds:
Thanks for reading my first post!

I am fairly brand new to the Arduino and electronics in general but I have some really cool ideas that I am trying to make a reality, I am just lacking a lot of background knowledge. Here's my issue:

I have a project involving a photoresistor and I was attempting to use pushbuttons as well but I don't know if what I am trying to do is feasible with them. I want an event to trigger when the photoresistor drops below a certain value. However; I want that event to change depending on which button I am pressing at the time and only when that button is being pressed.

I bought some normally open momentary pushbutton switches but they don't have any output (that I am aware of at least) and the regular 6mm pushbuttons seem to switch between on and off. I tried using code to reset the buttons state but I need it to stay on for variable lengths of time. Is there some better hardware I should consider trying to use?

Thanks again!

What do you mean by "they don't have an output"? How are they wired up? Are you using internal or external pull-up/pull-down resistors? What "code" did you try to "reset the buttons state"?

Here are the switches I tried using from RadioShack: RadioShack.com Official Site - America's Technology Store

I am not sure what you mean by internal or external pull-up/pull-down resistors.

This is the code I was attempting to use, I probably should have phrased it as button state change: http://arduino.cc/en/Tutorial/ButtonStateChange

braveneuroworlds:
I am not sure what you mean by internal or external pull-up/pull-down resistors.

Which probably means you don't have one. Without it, your output floats.

This is the code I was attempting to use, I probably should have phrased it as button state change: http://arduino.cc/en/Tutorial/ButtonStateChange

And did you wire it up in the picture? What output are you getting on the Serial monitor?

When I run the code from the tutorial:
on
number of button pushes: 1
off
on
number of button pushes: 2
off
on
number of button pushes: 3
off
and so on...

I don't think this code will work for my purposes because I want say, a sound file to be played, if the button is being held down when the photoresistor is triggered and I don't want it to stop when I release the button. As I talk it through with you though, it sounds like I would just need to do some code ju jitsu to make sure that my sound file doesn't stop when I release the button. Am I partially on the right track?

braveneuroworlds:
As I talk it through with you though, it sounds like I would just need to do some code ju jitsu to make sure that my sound file doesn't stop when I release the button. Am I partially on the right track?

Whether or not you have to do some "code ju jitsu" entirely depends on what the event is. You say you a sound file to be played. Since the Arduino can't natively play sound files, you're obviously going to need additional hardware. More than likely, you won't even need to detect the signal edge. Simply check the photoresistor value, If it's within your target value, check the state of your switches. Decide from there what sound file to play and tell whatever device you are using to play it. Set a flag variable so that it won't play it again until some other condition is met which clears this flag variable.

Yeah, that sounds about right. As a proof of concept I have been using a piezo but as I am getting further along it appears I will need much more. Thank you for all of your help!