It uses conduct threads in stead of regular metal wires so that it enable to make a wearable art work or interactive wall cloth.
I did a following experiment with Lily pad; however, I do not recommend you to do a same thing with me since I did not planed perfectly and it was the first time trial.
I made a gloves with LED. If I press or hold something with finger, the color of LED will be changed.
Requirement
Lily pad Arduino
conduct thread
power supply for Lily pad Arduino
AAA battery
10K resistor
Force sensor
LED that came with Lily Pad
Sewing Stuffs (needle, thread)
Cloth or material which you want to be sewed
Warning: this experiment potentially causes unexpected danger to you and Arduino.
Be safe when you do a experiment with Lily Pad.
If you find anything that unexpected result, plug out power charger( USB or battery ).
I actually almost broke down the circuit of the LilyPad because of shorts of the circuit.
First thing that you need to do is to imagine the final form of the circuit.
It must be better to spend a time to figure out how you sew thread to the glove.
I am sure that you will encounter a lot of problems while you are sewing since I also encountered a lot of problems.
Basic idea of circuit
As you see some of the threads nearly touch each other, that really bad.
I should have planned more nicely.
Program
int ledPin=10; // declare variables int ledPin2=10; int pressure=0; int val,val2; void setup() { pinMode(ledPin, OUTPUT); //setup pin } void loop() { val = analogRead(pressure)/4;
//load data and convert it to suitable value for PWM val2 = 255-val;
//load data and convert it to suitable value for PWM analogWrite(ledPin, val); delay(400); analogWrite(ledPin, val2); delay(400); }
10k Ohm Resister(any valued resistor is fine but it is hard to get a signal if you use lower resistor and it is potential risk to break down analog input if you use too high resistor)
piezo
wires
Arduino
This exercise is very simple.
Circuit
I wrongly put a LED in a picture but it does not do anything.
Program
I made a very simple program to check
void setup() { Serial.begin(9600);//setup serial speed } void loop() { Serial.println(analogRead(0)); // gets data from analog pin 0 and send to computer delay(500); //not to send too much information }
It actually the resistor is critical for this circuit.
I originally used 100k ohm resistor but the value of analog signal was so tiny.
Also the result is deeply depend on piezo itself. I tried three different piezo but they send back different amount of values.
This tutorial is based on the PDF page 35 about servo, and I changed program to check my understanding of the tutorial.
The PDF tutorial has a good information but the program seems complex. I simplified a program and add a little function.
In the following tutorial I am going to explain the way to control servo motor in a different way that explained in a tutorial of the Arduino web page.
In way that is introduced in a Arduino web page is use servo library to control the servo motor. Therefore, only pin9 and pin10 is available for servo.
However, the pin 9 and 10 has a function of pwm and you might want to use them for other purposes.
This tutorial enable you to use any digital pin to control servo motor.
Requirements
Servo motor
(you may need a pin that has three legs both side to connect servo to the board)
10K resistor
Switch
Wires
Arduino
Before we start we need to understand more about servo motor
"Servo motors have three wires: power, ground, and signal. The power wire is typically red, and should be connected to the 5V pin on the Arduino board. The ground wire is typically black or brown and should be connected to a ground pin on the Arduino board. The signal pin is typically yellow or orange and should be connected to pin 9 on the Arduino board."
I found additional useful information from Wikipedia
"A servo pulse of 1.5 ms width will set the servo to its "neutral" position, or 90°. For example a servo pulse of 1.25 ms could set the servo to 0° and a pulse of 1.75 ms could set the servo to 180°. The physical limits and timings of the servo hardware varies between brands and models, but a general servo's angular motion will travel somewhere in the range of 180° - 210° and the neutral position is almost always at 1.5 ms."
Now we got a enough information to program and build up circuit, so that let's try based on these information.
Circuit
Program
/*
This program is enable you to rotate a servo motor without using a Arduino library.
If you hit a switch the motor will rotate opposite direction.
*/
int ledPin=3;//switch int pin=2;//for servo motor control int val; int offCount = 1450;// you can change the rotation of the servo motor int onCount = 1550;//same as here
void setup() { pinMode(pin, OUTPUT);//set up pins pinMode(ledPin, INPUT); } void loop() { val= digitalRead(ledPin); // get data from switch if (val==false)
//check whether switch is on or off you can use 0 instead of false { digitalWrite(pin, HIGH); //send a pulse delayMicroseconds(offCount);//it is important for servo motor digitalWrite(pin, LOW); delay(20);// also important. If you omit it, the motor do not work properly. } else {
// when you switch on digitalWrite(pin, HIGH); delayMicroseconds(onCount); digitalWrite(pin, LOW); delay(20); }
}
If you put a value 1500 at offCount or onCount ot both the motor does not work but it does not mean broken but it is balanced.
I do not know how much angle does our servo motor can take, but we can put a value from 1250 to 1750 safely.
The below program is based on the things that I learned in the PDF document page 16 to 26.
Learned: complex condition cords with "if" and "while".
This original program tells the value from analog input, which is connected to the Potentiometer, with Green LED and Red LED and sound.
If the analog input got more electrical flow, Arduino lights Green LED. If the flow is middle, Arduino lights Red LED. If the flow is low or none, Arduino tells us through the speaker.
I use commends that learned through the PDF exercise, in order to check my understanding.
Requirements
Arduino basic kit(two LEDs, possibly red and green; speaker; potentiometer and wires)
Resistor (more than 2. The number depend on how much Ω is it)
Program
/*
This is a middle part of the exercise of PDF p16-26
http://www.lulu.com/items/volume_63/1108000/1108699/4/print/ARDUINO_NOTEBOOKv6.pdf
This exercise contains mainly
if else
while
random(min,max)
This program is made to check my understanding of the contents of the PDF.
This program also requires my original circuit setup. I will post it on my blog.
*/
int digiPin=13;
int digiPin2=2;
int digiPin3=7;
int anaPin=0;
int val;
int duration;
void setup()
{
Serial.begin(9600); //setup serial seep
pinMode(digiPin, OUTPUT); //setup digital pins
pinMode(digiPin2,OUTPUT);
pinMode(digiPin3,OUTPUT);
}
void loop()
{
val=analogRead(anaPin); //get a value from analog pin 0
if (val > 500) //if analog pin 0 got more than 500, do followings
{
digitalWrite(digiPin, HIGH); //light up LED at digital pin 13
delay(val); //dulation is decided by the value of analog value
Serial.println("more than 500"); //send back from Arduino
digitalWrite(digiPin, LOW);
delay(1000);
}
else // if analog pin 0 got less than 500, do followings
{
while(val<=300)// if analog pin 0 got less than 300, do play a sound
{
tone(digiPin3, 494, 500); // command for sound
delay(500);
val=analogRead(anaPin); // This step is important. If you forget it, you can't go out of while loop
}
// if value is 300
Serial.println("midium and random duration");
digitalWrite(digiPin2,HIGH); //turn on LED connected to digital pin 2.
duration = random(1000,3000); // LED lights from 1 to 3 second
delay(duration);
digitalWrite(digiPin2,LOW);
duration = random(1000,3000);
delay(duration);
}
}
val=analogRead(anaPin); is important in the while loop. I did not put this commend at first so that the program did not work what I wanted. It was a good study.
The below program is based on the things that I learned in the PDF document page 1 to 15.
Discovery : "Array", which can store values, is very useful.
This program light the led that connected to the digital pin #13 for 0.01 second 5 times and send a message back to the computer.
Requirement
Arduino + LED (If you use digital pin 13 and have a proper LED)
or
Arduino + LED + resister and wires(same as picture below)
Program
/* This is a program that to show thigs that I learned from http://www.lulu.com/items/volume_63/1108000/1108699/4/print/ARDUINO_NOTEBOOKv6.pdf Page 1 to 15 I am going to include commend as much as possible. */ /* This is a block comment. I can write any thing in this section. */ // This is also comment. line comment
//list of variables int variable;//integer that declares variables. most commonly used. 16bit 32,767 to -32,768. int abc, def, ghi; // variables can take this form int pin=13; // and also it can take this form int y = 1; byte b; //8 bit 0-255 long l; //32 bit 2,147,483,647 to -2,147,483,648 float f; //32 bit 3.4028235E+38 to -3.4028235E+38 double dob; // other form of varable for floating decimal char ch; // also other form of variable. char has a different function from int int delayValA[ ]={10, 3000, 5000}; //arrays that can stor the values
void setup() { //defines the starting point of function Serial.begin(9600); // setup connection speed 9600 is good for my arduino // very important. if you do not get respond from Arduino it must be because of this command
//void setup is the first function of the program pinMode(pin, OUTPUT); // sets the 0pin as out put
}//defines the ending point of function void loop() { for (int i=1; i<=5;) // this variable works only in the for loop
{
i++; // increment. there is many increment and decrement such as -- ++ *=
Serial.println(i);
digitalWrite(pin,HIGH);//send high signal(1)to the pin
delay(delayValA[1]); // delay the commend digitalWrite(pin,LOW);//send low signal(0)to the pin delay(delayValA[2] + 1000); //arithmetic works like this digitalWrite(pin,HIGH);//send high signal(1)to the pin delay(delayValA[1]); // delay the commend digitalWrite(pin,LOW);//send low signal(0)to the pin delay(delayValA[2] + 1000); //arithmetic works like this } Serial. println("out of for loop "); //println is use for send a message from Arduino delay(delayValA[3] + 2000); }
Actually, the PDF does not explain "for" commend and it is not easily understandable.