Archive | November, 2011

Using a switch

22 Nov

Continuing with the experiments on our Tron-like LED bracelet we added a switch to make it more comfortable to turn the Lilypad on and off without having to touch the board.

We used alligator clips for this experiment, but you can also use conductive thread.

Start by attaching the On pin of the switch to one of the digital pins of the board (we used the pin 5) and the Off pin to the – pin of the board. Then connect your Lilypad to the computer and add the switch in your code. We kept the LEDs blinking like in the previous example.

Source code:

int ledPin = 6; // LED is connected to digital pin 6
int switchPin = 5; // switch connected to digital pin 5
int switchValue; // a variable to keep track of when switch is pressed

void setup()
{
pinMode(ledPin, OUTPUT); // sets the ledPin to be an output
pinMode(switchPin, INPUT); // sets the switchPin to be an input
digitalWrite(switchPin, HIGH); // sets the default (unpressed) state of switchPin to HIGH
}

void loop() // run over and over again
{
switchValue = digitalRead(switchPin); // check to see if the switch is pressed
if (switchValue == LOW) { // if the switch is pressed then,
digitalWrite(ledPin, HIGH); // turn the LED on
delay(1000); // wait for a second
digitalWrite(ledPin, LOW); // set the pin 6 LED off
delay(1000);
}
else { // otherwise,
digitalWrite(ledPin, LOW); // turn the LED off
}
}

Advertisements

Second step: a LEDs bracelet

17 Nov

Connecting the Lilypad to the cloth, with 5 white LEDs in a row and conductive thread.

Source code:

/*
Blink
Turns on a series of LEDs on for one second, then off for one second, repeatedly.

This example code is in the public domain.

Modified by smartcraftLab on 2011
*/

void setup() {
// initialize digital pin 6 as outputs.
pinMode(6, OUTPUT); // Pin 6 is connected to an LED

}

void loop() {
digitalWrite(6, HIGH); // set the pin 6 LED on
delay(1000); // wait for a second
digitalWrite(6, LOW); // set the pin 6 LED off
delay(1000); // wait for a second
}

First steps

10 Nov

In our first meeting as a group, we got familiar with the Lilypad Arduino board, its digital and analog pins and we started to experiment with LEDs. We started by connecting one white LED in our Lilypad board and then we added one more and programmed them to blink one at a time.

We experimented with the Blink example that comes with the Arduino 0.22 platform. Source code:

/*
  Blink
 Turns on an LED on for one second, then off for one second, repeatedly.

 This example code is in the public domain.

 Modified by smartcraftLab on 2011
 */

void setup() {
  // initialize the digital pins as outputs.
  pinMode(5, OUTPUT); // Pin 5 is connected to an LED
  pinMode(6, OUTPUT); // Pin 6 is connected to an LED

}

void loop() {
  digitalWrite(5, HIGH); // set the pin 5 LED on
  digitalWrite(6, LOW);  // set the pin 6 LED off
  delay(1000);           // wait for a second
  digitalWrite(6, HIGH); // set the pin 6 LED on
  digitalWrite(5, LOW);  // set the pin 5 LED off
  delay(1000);           // wait for a second
}

A introduction to Lilypad Arduino

10 Nov

The LilyPad Arduino microcontroller is a set of sewable electronic components that let you build your own soft, interactive clothes, fabrics, embroideries or even drawings if you use it with conductive ink. It is created by Leah Buechley, an MIT professor and director of the High-Low Tech Group and by Sparkfun Electronics. It is programmed with the Arduino open-source platform.

If you are interested in soft circuits and using the Lilypad, start by consulting the Setup Tutorial by Leah Buechley:http://web.media.mit.edu/~leah/LilyPad/01_computer_attach.html

And check out this cool and orientating powerpoint introduction we found on-line.
View more presentations from marrije