# Don't understand how sensor works, metal wired directly to I/O pin of arduino

I'm trying to understand how an electronic musical instrument (called an e-chanter) works (imagine a recorder or other wind instrument, but with the holes replaced with metal contacts, and the sound played electronically, so no air is needed).

Basically, there are several metal contacts, as shown in this link: http://www.echanter.com/home/howto-build#TOC-WIRES-SCREW-SENSORS

They each appear to be wired only directly to one pin of the arduino:

I can't figure out for the life of me how this works. Can anyone explain it, are the fingers being used as some kind of ground or what on earth is going on. I have a physics background so can understand some technical info, but just can't fathom how on earth this magic works.

Thank you very much

• I've now realised that it's a capacitive proximity sensor, but I still don't understand how it can work with only one input to the arduino..? Feb 9, 2015 at 2:36
• You said "They each appear to be wired only directly to one pin of the arduino" How is that one input? Feb 9, 2015 at 6:43

According to his code, he seems to be taking advantage of the fact that simply touching the digital input pins with your finger will cause a measurable change in signal:

/* Read the relevant pin registers and construct a single byte 'map'   */
/* of the pin states. Touched pins will be HIGH, untouched pins LOW    */

byte fb = 0;
byte fmap = 0;  //D2-D7 (bits 2,3,4,5,6,7)
fmap = PIND >> 2;  // get rid of lowest 2 bytes,  fill top 2 bytes


In other words, there are no moving parts in his design.

I'm not sure of the exact circuitry that would allow this to work on an the Arduino, but it would be something along the lines of this AC hum touch switch:

Essentially, that the presence of a finger (which is a conductor) creates just enough change in the circuit to flip the digital bit.

Maybe they are using the capacitance of your hand touching the screw?

In this article the pin is first pulled low, and then the software measures how long it takes to charge it back up through the pull up resistor. If a finger is touching the sensor, it increases the sensor's capacitance, resulting in longer charging times.

(Don't ask me about any details, though -- I just remembered seeing the article a while ago, I don't have any experience with this.)

• Looking at the project's code this is indeed the case. Mar 13, 2015 at 18:46

The DIY article is not written very well. It seems the author is using "screw sensors", which I can only imagine is a DIY type of mechanical-switch-type sensor, where the screws complete the circuit to the Digital IO (DIO) pins.

I think it would be something like:

0V or 3.3/5V ------> switch (sensor) ------> Arduino Pin

Usually an open switch in this configuration would produce a floating input to the arduino, however many (if not all) Arduinos have an inbuilt pull-up resistor to the DIO pins. Taking advantage of this it is simple to differentiate between the default pull-up (HIGH) state and a ground (LOW) state using only the ground signal being toggled by a switch.

I looked in the arduino source and it confirms that there are multiple switch-type sensors and a single analog pressure sensor.

No, the fingers are not working as GND or other things, they just press the switch.

The switch inside should look like this: (or exchange switch and R if pin is init as LOW base)

----- VCC | R |-----pin of Arduino | \ the switch | | _|_ GND

Before you press the switch, the voltage of pin is VCC.

After you press the switch, the voltage of the Arduino pin is 0, since there is a resistance R.

The Arduino uses a ADC (Analog to Digital Converter) to detect the signal based on the input voltage, then it knows there was a HIGH signal and then it is LOW. So the system do something based on the change.

As for the pressure sensor, it works as a sliding rheostat and doesn't go through the ADC, so it is a continuous analog signal which can express the pressure value.