Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
fabricademy2017:students:julie.taris:class9-e-textiles-wearables2 [2018/06/25 20:56]
julie_taris
fabricademy2017:students:julie.taris:class9-e-textiles-wearables2 [2018/06/30 17:41]
julie_taris
Line 179: Line 179:
 \\  \\ 
 === Arduino tests === === Arduino tests ===
 +== connect an analog sensor to the Arduino==
 +See the instructable here : [http://​www.instructables.com/​id/​Connecting-a-textile-analog-sensor-to-Arduino/​|Connecting a Textile Analog Sensor to Arduino]]
  
-[http://​www.instructables.com/​id/​Connecting-a-textile-analog-sensor-to-Arduino/​|Connecting a Textile Analog Sensor to Arduino]] 
  
-{{vimeo>​245700846?​medium}}+  * Connect the '​+'​ pad of your Lilypad to your sensor. Sensors are not polarized, so it does not matter on which side you connect it. 
 +  * Connect the output of the sensor to the analog input a0 of the Lilypad 
 +  * Connect Sensor to Ground.
  
-{{vimeo>​245700018?​medium}}+ 
 +Plug the USB cable into your USB port of your laptop, and into the USB port of the FTDI board and copy, paste and upload the following program to the Lilypad: 
 + 
 + 
 +<​code>​ 
 +int softPot = 0; // this line selects the input pin a0 for the sensor 
 +int ledPin = 13; // this line selects the pin 13 for the LED output 
 +int tempPot = 0; // variable to store the value coming from the sensor 
 + 
 +void setup() ​{ 
 +// this line declares the ledPin as an OUTPUT: 
 +pinMode(ledPin,​ OUTPUT); 
 +
 + 
 +void loop() ​{ 
 +// read the value from the sensor and store the value in the variable tempPot 
 +tempPot = analogRead(softPot);​ 
 +// it turns the LED on 
 +digitalWrite(ledPin,​ HIGH); 
 +// stop the program for milliseconds:​ 
 +delay(tempPot);​ 
 +// turn the LED off: 
 +digitalWrite(ledPin,​ LOW); 
 +// stop the program for for milliseconds:​ 
 +delay(tempPot);​ 
 +} 
 +</​code>​ 
 + 
 +upload the sketch into the lilypad and open the monitor 
 +we can see the voltage variation between O (the sensor is not stretched) and different more or less intense variations (if the sensor is stretched, twisted, bent...)
  
 {{vimeo>​245699994?​medium}} {{vimeo>​245699994?​medium}}