Go Down

Topic: LilyPad Button Board: Attaching to LilyPad and Coding the Listener (Solved) (Read 2881 times) previous topic - next topic


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)?


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. :)

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. :) Thanks to all who viewed the thread. My problem is solved, however, so it is fine for this thing to fall to the depths. ^_^


So you're connecting + of Lilypad to S of the button, and - to ground of Lilypad ? But then how to read the value ??

The code you mention connects S of the button to 7 of Lilypad...

Go Up