Ho boy... it seems that with every new component I add to my project, I run right into another brick wall. :/ Well, on to the current issue.
I've built a circuit that, so far, blinks LEDs and beeps a buzzer when I want it to. I'm sure that sounds ridiculously simple to most of you, but for me, it's a huge deal.
I'm still a newbie, after all. Anyway, my next task is to incorporate a pushbutton into the mix, and I've got a LilyPad button board to go with my LilyPad.
So here's what I want it to do. Right now, when I provide power to the circuit, my seven LEDs turn on, I make a beep with the buzzer, and then the LEDs turn off. Lather, rinse, repeat. You get the idea. What I want to happen instead is for the loop() function to listen for a button press+release before doing anything else. When it detects that the button has been pressed and released, it will begin the LED and buzzer loop, and continue it until the button is pressed and released a second time. The whole thing will repeat the cycle: every odd button press+release results in the activity with the LEDs and Buzzer, and every even button press+release results in the activity stopping.
So here are my issues with making this happen. My first problem is that I'm very confused about where to place my resistors and how to hook the button up to my LilyPad. After reading the Arduino Button Tutorial
and the Arduino Button State Change Tutorial
, I'm still not quite clear. My LilyPad button board has two pin holes: one marked with an S and one marked with a -. Am I correct in ascertaining that I should connect the - side to the 10k resistor, and connect THAT to ground? Then connect the S side to the pin on my LilyPad? Do I also need a 100 resistor somewhere in there? I'm still not clear on the whole pullup vs. pulldown resistor thing.
Finally, for the code, will the code on the Arduino Button State Change Tutorial
be the right place to start, or is that meant for a special kind of state-saving button instead of a momentary push-button (like I have)?