Introduction: Connecting a Textile Analog Sensor to Arduino

Picture of Connecting a Textile Analog Sensor to Arduino


This instructable explains how to connect an analog sensor to the Arduino (in our case will use a Lilypad).

Material you will need:

- one Lilypad Arduino (www.sparkfun.com)
- one FTDI board (www.sparkfun.com)
- one USB A to mini B cable (www.sparkfun.com or Radio Shack)
- one analog textile press button or a stretch sensor (www.plugandwear.com)
- 4 crocodile cables (Radio Shack)
- a 10 kOhm resistor (Radio Shack)
- a 1 kOhm resistor (Radio Shack)
 
Brief introduction:
While DIGITAL sensors are able to detect only two levels (HIGH or LOW, ON or OFF, TRUE or FALSE, 0V or +5V), ANALOG sensors are used to detect physical quantities with different levels (i.e. a pressure sensor measuring weight from 0 Kg to 5 Kg).
At each variation of the pressure (sensor input), a proportional variation of its output will occour.

For our instructable we will use a textile resistive sensor that changes its resistance with applied mechanical pressure. The more weight we apply to the sensor, the lower its electrical resistance will be.

Lilypad is not able to read resistance, so we'll have to convert our variation of resistance into a variation of VOLTAGE, that is something the Lilypad can read. We'll do this using the circuit in the image.

This circuit is able to transform a RESISTANCE variation of VR1 (our sensor) into a VOLTAGE variation. You can verify by putting your multimeter on Ohm and read the voltage between 0V and the sensor output.





Step 1: Connect the Sensor 1

Picture of Connect the Sensor 1


Using one crocodile cable (RED if you have one, as RED is the color for positive) connect the '+' pad of your Lilypad to your sensor. Sensors are not polarized, so it does not matter on which side you connect it. This procedure is shown for an analog textile press button, but the same one could be applied for a stretch sensor.

Step 2: Connect the Sensor 2

Picture of Connect the Sensor 2


Then connect the output of the sensor to the analog input a0 of the Lilypad. You can choose a different input later in the sketch (the Lilypad program).

Step 3: Connect Sensor to Ground

Picture of Connect Sensor to Ground


Then connect the output of the sensor to the 1 kOhm resistor, and the other terminal of the resistor to "-" pad on the Lilypad (BLACK cable, because black means ground, or 0V).



Step 4: Sketch

Picture of Sketch


The program the Lilypad will execute is called 'Sketch'.

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:

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);
}


Once completed you should see the LED on the Lilypad blinking. By pressing the button the LED should blink at a slower frequency.

You might even want to do the following exercises:


1. Switch off and replace the 1 kOhm resistor with the 10 kOhm resistor and see the difference.
2. Switch off and swap the resistor and the sensor in the schematic of step 1. See what has changed.





 

Comments

CosminR (author)2014-11-27

Hello, i really love the ideea but since i am a noob when it comes to arduino, i would like to ask: How many pressure sensors can be conected to a single arduino?

Thank you.

rmarchesi (author)CosminR2014-11-27

Minimum 5 Analog and 12 digital

diy_bloke (author)rmarchesi2016-05-28

I would think maximum (not minimum) 5 analog.
12 digital true, but not many digital pressure sensors in the DIY world.
btw on a Nano and some mini's there are 7 analog ports

About This Instructable

11,463views

20favorites

License:

Bio: Electronic engineer with 25 years experience in textiles. Currently working on interactive fabrics.
More by rmarchesi:Connecting a textile analog sensor to ArduinoHow to connect solar cells to fabricHow to make (and connect) a soft potentiometer
Add instructable to: