Pages: [1]   Go Down
Author Topic: LilyPad Button Board: Attaching to LilyPad and Coding the Listener (Solved)  (Read 751 times)
0 Members and 1 Guest are viewing this topic.
My own little world
Offline Offline
Newbie
*
Karma: 0
Posts: 18
If at first you don't succeed, smack it harder.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley 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)?
« Last Edit: April 15, 2011, 05:42:03 pm by Shuko » Logged

Being an adult shouldn't be about maturity; it should be about being old enough to go out and do bigger and better things with your time.

My own little world
Offline Offline
Newbie
*
Karma: 0
Posts: 18
If at first you don't succeed, smack it harder.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Eureka! Success!

Judging from the number of views, I thought it possible that some folks were interested in the answers to my questions, but didn't really have them. For you folks, here's what I found out.

Apparently, the LilyPad Button Board is meant to be connected directly to the Lilypad pins and the ground. The S-pin of the button connects to the I/O pin of your LilyPad, and the -pin connects to ground. That part of it is extremely simple, so there we go. smiley

As for the code, it is also surprisingly simple! I ran across this page while desperately searching for anyone with instructions on this subject, and it gave me everything I needed. Their code snippet is good for simply capturing the button presses, but it helped my purposes immensely. smiley Thanks to all who viewed the thread. My problem is solved, however, so it is fine for this thing to fall to the depths. smiley-kitty
Logged

Being an adult shouldn't be about maturity; it should be about being old enough to go out and do bigger and better things with your time.

Pages: [1]   Go Up
Jump to: