Pressure sensor- works with 9v + led, not arduino!

Hi friendly arduino people!

I'm slightly at my wits end. This should be fairly simple.

I've made a pressure sensor as per this tutorial: It gives a beautiful response when I hook it up in series with a 9V battery and LED, giving a brightness proportional to how hard it is pressed (brighter= harder) and no light at all when it's not pressed.

What I want is to count the number of times it is touched and display it either on my computer or on a liquid crystal display. I would have thought that wouldn't be too hard.

When I hook it up to a multimeter it gives a high (infinite) resistance when not touched and a value anything between about 100 to 200 ohms when pressed.

It basically acts as a variable resistor, but all the arduino programs for variable resistors are potentiometer based, and i have no idea how to substitute my sensor for the pot (like this one...

I tried following the tutorial for "knock", for a piezoelectric sensor, but got a strange little error and no readings.

I tried using the program suggested by the author of the instructable, but got no response out of that either ( sat stubbornly at "0", whatever "0" for an analog input pin means...)

If anyone can give me any kind of help that would be amazing.

Huge thanks,


The magic question is: do you want it to simply act like an on/off switch? Or do you want to get some rough analog reading of how much pressure is being applied?

To use is as a switch, just connect it between a digital pin and ground, and enable the internal pull-up on the pin (configure the pin as an input, then write a HIGH to it). You'll see a high input with no pressure, and a low when it's pressed.

For an analog reading, you'll need to crate a voltage divider similar to that in the potentiometer examples. Connect a fixed resistor to +5, connect the sensor to ground, and then connect the free end of both to an analog pin.

The sensor seems to be okay handling LED current, so I'd suggest the fixed resistor be a 330 or 510 Ohm. Maybe 1K to be safe, but that could be over-doing it.

You should see an analog reading at/near 1023 with no pressure, going down to the low hundreds depending on the amount of pressure applied.

Thank you for your help!

ok, i'd be happy for it to act like an on/off switch. The thing is, what sketch do i need to run for that? where do i read the output? on the serial monitor? I guess i'd need to write a different program to track the number of presses and read that out somewhere...

For the analog, what sketch do i need to put on the arduino? the resistor value help is really appreciated though!

also, when the thing is attached to a 9v and an led, it heats up with use. is this something i should be worried about?

I'm really sorry to be such a noob at this!


Ah! i seem to have had some measure of success playing around with the code! I'm going to see if i can print out to a lcd with debounce code now...