Lilypad - Button and Slider

Button

button.jpg
Lilypad Button

Description:

Push button.

Connecting:

1. Connect the negative petal of the button to the negative petal on the Lilypad Main Board.
2. Connect the positive petal of the button to one of the digital I/O pins e.g. 2.

NB: If you are using alligator leads to prototype then make sure that the teeth of your clips make good contact with the metal parts of the sensor petals. If not, you will get inconsistent results.

Getting Data From:

The key method for getting data from a button or slider is to read its state using the digitalRead function. If the value is HIGH then the switch is not pressed. If it is LOW then the switch is pressed. Usually you would then use a conditional statement so that you can make one thing happen if the button is pressed and another happen if the button is not pressed (e.g. turning an LED on and off). The example script below turns an LED on and off in response to a button and is based on Leah Buechley's tutorial (see links below).

buttonSimple.gif
Using a Button to control an LED

Links:



Slider

slideSwitch.jpg
Lilypad Slide Switch

Description:

Slide button.

Connecting:

1. Connect the OFF petal of the button to the negative petal on the Lilypad Main Board.
2. Connect the ON petal of the button to one of the digital I/O pins e.g. 2.

NB: If you are using alligator leads to prototype then make sure that the teeth of your clips make good contact with the metal parts of the sensor petals. If not, you will get inconsistent results.

Getting Data From:

Use same approach as button example above.

Links: