I eventually want to make things like the fire walker shoes, but right now I'm just trying to wrap my brain around the concept of the velostat sensor.
I did buy some velostat and conductive thread. I had both an arduino mega and an uno on hand, so I took the test circuit code from this page:
https://learn.adafruit.com/firewalker-l ... st-circuit
removed the parts that had to do wit the led strip, so all I really have is something that should print the sensor values.
Then I took a couple of heel shapes pieces of velostat, taped conductive thread on either side, and then used alligator clips and probes to connect them to ground and A9 of my arduino mega.
The value printed from the code is bouncing slightly between 230 and 320 -ish, but does not seem to change at all when the velostat is pressed.
Is there something special about a flora port A9?
I also wondered why in the code you have a constant set to nine, but in the code you don't use the constant, instead you use a 9.
Now, from what I understand, if you want to measure resistance, you need to provide power, and most circuit diagrams that use a dial (pot) include the 5 volt power line. How does this velostat stuff work without power?
My code is merely this:
const int analogInPin = 9; // Analog input pin that the potentiometer is attached to
int sensorValue = 0; // value read from the pot
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
pinMode(analogInPin, INPUT_PULLUP);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// print the results to the serial monitor:
Serial.print("sensor = " );
Serial.println(sensorValue);
delay(100);
}
Velostat & any arduino
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- Franklin97355
- Posts: 23911
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Velostat & any arduino
Not sure you want the pullup on an analog reading.
- jonwa
- Posts: 40
- Joined: Sun Oct 23, 2011 7:56 pm
Re: Velostat & any arduino
INPUT_PULLUP was what the original code had.
It's on the adafruit tutorial that way.
It's on the adafruit tutorial that way.
- jonwa
- Posts: 40
- Joined: Sun Oct 23, 2011 7:56 pm
Re: Velostat & any arduino
hmmm, apparently there is a difference between
pinMode(A9, INPUT_PULLUP);
and
pinMode(9, INPUT_PULLUP);
that I do not understand. I need to go read up on this more...
pinMode(A9, INPUT_PULLUP);
and
pinMode(9, INPUT_PULLUP);
that I do not understand. I need to go read up on this more...
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Velostat & any arduino
The pull-up resistor/pot makes the top half of a voltage divider. The Velostat makes the bottom half.
Velostat contains carbon black, which is conductive, and when you compress it the number of particles in contact.. thus capable of carrying current.. increases. The upshot is that the Velostat acts like a rough pressure sensor.
The changing resistance isn't a specified feature of Velostat though.. it's a side effect we discovered and thought was cool. You'll have to adjust the code to work for the set of readings you get.
Pin A9 is an analog input connected to the internal ADC. Pin 9 is a digital I/O pin. We use the ADC to measure the change in voltage at the middle of the pull-up/Velostat voltage divider.
Velostat contains carbon black, which is conductive, and when you compress it the number of particles in contact.. thus capable of carrying current.. increases. The upshot is that the Velostat acts like a rough pressure sensor.
The changing resistance isn't a specified feature of Velostat though.. it's a side effect we discovered and thought was cool. You'll have to adjust the code to work for the set of readings you get.
Pin A9 is an analog input connected to the internal ADC. Pin 9 is a digital I/O pin. We use the ADC to measure the change in voltage at the middle of the pull-up/Velostat voltage divider.
- jonwa
- Posts: 40
- Joined: Sun Oct 23, 2011 7:56 pm
Re: Velostat & any arduino
That clears things up a bit. There are odd differences with different pins. I was rather hoping to build this project using a couple of digisparks, but I'm not sure how to figure out if it has an equal pin to the A9.
- Franklin97355
- Posts: 23911
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Velostat & any arduino
Since A9 is an analog pin just check the specs of the digispark.but I'm not sure how to figure out if it has an equal pin to the A9.
- jonwa
- Posts: 40
- Joined: Sun Oct 23, 2011 7:56 pm
Re: Velostat & any arduino
No luck so far with getting velostat and a digispark chip to work.
The digispark says every digital pin can also be analog and pin 5 is merely labeled d/a so I'm figuring it ought be viable.
Couple of tricks so far.
1. The constant INPUT_PULLUP was missing in the digispark stuff, so I had to add it as a #defined
2. there is no serial monitor with digispark, so instead you use this library that turns the digispark into a keyboard, and you have it type into notepad for you.
In any case, my current test code just prints 4s and 5s over and over, instead of values over 100 normally, and under 100 when velostat is pressed.
I did get my chunk of velostat to work with an arduino mega, so that part ought be fine.
I've posted this issue also on the digispark forums, hopefully someone knows something that can help me understand what's wrong.
Here's my digispark code.
#include "DigiKeyboard.h"
#define ANALOG_IN 5
#define INPUT_PULLUP 0x2
int sensorValue = 0;
void setup() {
pinMode(ANALOG_IN, INPUT_PULLUP);
}
void loop() {
DigiKeyboard.sendKeyStroke(0);
sensorValue = analogRead(ANALOG_IN);
// print the results to the serial monitor:
DigiKeyboard.println(sensorValue);
delay(500);
}
The digispark says every digital pin can also be analog and pin 5 is merely labeled d/a so I'm figuring it ought be viable.
Couple of tricks so far.
1. The constant INPUT_PULLUP was missing in the digispark stuff, so I had to add it as a #defined
2. there is no serial monitor with digispark, so instead you use this library that turns the digispark into a keyboard, and you have it type into notepad for you.
In any case, my current test code just prints 4s and 5s over and over, instead of values over 100 normally, and under 100 when velostat is pressed.
I did get my chunk of velostat to work with an arduino mega, so that part ought be fine.
I've posted this issue also on the digispark forums, hopefully someone knows something that can help me understand what's wrong.
Here's my digispark code.
#include "DigiKeyboard.h"
#define ANALOG_IN 5
#define INPUT_PULLUP 0x2
int sensorValue = 0;
void setup() {
pinMode(ANALOG_IN, INPUT_PULLUP);
}
void loop() {
DigiKeyboard.sendKeyStroke(0);
sensorValue = analogRead(ANALOG_IN);
// print the results to the serial monitor:
DigiKeyboard.println(sensorValue);
delay(500);
}
- Franklin97355
- Posts: 23911
- Joined: Mon Apr 21, 2008 2:33 pm
- jonwa
- Posts: 40
- Joined: Sun Oct 23, 2011 7:56 pm
Re: Velostat & any arduino
"I've posted this issue also on the digispark forums..."
Please be positive and constructive with your questions and comments.