Go Down

Topic: Arduino Nano and Velostat (Read 86 times) previous topic - next topic

N7Fenrir

Jul 14, 2018, 12:10 pm Last Edit: Jul 14, 2018, 12:12 pm by N7Fenrir
Hello Everyone,

I am currently trying to build a small pressure sensor using Velostat and Arduino Nano. I have connected the crocodile pins to GND and to A0 analog pin. The conductive loop tutorial is followed is here

https://learn.adafruit.com/firewalker-led-sneakers/make-velostat-step-sensors

The Code that I have is:

Code: [Select]


void setup() {
  Serial.begin(9600);
}

void loop() {
  int sensorValue = analogRead(A0);
  float voltage = sensorValue * (5.0 / 1023.0);
  Serial.println(voltage);
}



When I dont connect anything to the Nano, The output is like

Code: [Select]


1.30
1.30
1.29
1.30
1.30
1.29
1.30
1.30
1.30
1.30
1.30





When I connect the velostat to the Nano

Code: [Select]


0.00
0.00
0.02
0.00
0.00
0.09
0.00
0.00
0.12
0.00




I am not understanding if this is correct because even when I press the velostat the output is still the same. Can anyone help me rectify this ?

Thanks in Advance.

groundFungus

#1
Jul 14, 2018, 01:12 pm Last Edit: Jul 14, 2018, 01:34 pm by groundFungus
From the linked tutorial:
Code: [Select]

void setup() {
   // initialize serial communications at 9600 bps:
   Serial.begin(9600);
   pinMode(9, INPUT_PULLUP);  //****
   strip.begin();
   strip.show(); // Initialize all pixels to 'off'
}

Note that the internal pullup is enabled on the analog input (pin 9 on the Flora).

Quote
Velostat pressure sensor (described in the next step) connected to GND and pad marked D9 (this pin is also A9, and we will be using it as an analog input).
This may not apply, directly, to the Nano.  The point is that the analog input has the internal pullup enabled.

The reason is that the velostat is a resistor.  In order to measure resistance you need the unknown resistor (velostat) to be one leg of a resistor voltage divider.  The other leg of the voltage divider is the internal pullup.   Measuring resistance.

johnwasser

Since you are using a n Arduino Nano and not an Adafruit Flora you will need to provide a pull-up some other way (I think analogRead() disables the pull-up resistors on the analog inputs.)  You can set Pin 9 to INPUT_PULLUP and wire it to A0 (along with the wire from the Velostat).  Or you could use a fixed resistor (10,000 Ohms, maybe) between A0 (along with the wire from the Velostat) and +5V.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

N7Fenrir

Hi,

Thanks for your answers but I managed to solve it off by doing:

Code: [Select]


void setup() {
  Serial.begin(9600);
  pinMode(A1,INPUT_PULLUP);
  digitalWrite(A1, HIGH);
}

void loop() {
      int sensorValue = analogRead(A1);
      float voltage = sensorValue * (5.0 / 1023.0);
      Serial.print('T');

}



I was reading the documentation @

https://www.arduino.cc/reference/en/language/functions/digital-io/digitalwrite/

 and found:

Code: [Select]


If the pin is configured as an INPUT, digitalWrite() will enable (HIGH) or disable (LOW) the internal pull-up on the input pin. It is recommended to set the pinMode() to INPUT_PULLUP to enable the internal pull-up resistor. See the digital pins tutorial for more information.



So now It works as expected. However I have a new problem which I have posted in the "programming questions ", the new problem gist is of using pins to establish a SERIAL_UART connection between raspberry pi3 b+ and Arduino and sending these values to the raspberry pi 3 b+.

Go Up