Home LearningBasics Connecting a basic Touch sensor

Connecting a basic Touch sensor

by shedboy71
[lebox id="1"]

This example shows how to interface a basic touch sensor to our arduino, this sensor came as part of a kit of 37 sensors.

Touching the metal sensor pin produces an output at the ‘DO’ pin. The output is not a clean signal but craetes a 50 Hz mains induced signal . The output signal is ‘active high’ and the circuit sensitivity can be adjusted with the potentiometer. An analog output signal from the sensor is also available on pin ‘AO’.

touch sensor

touch sensor

These are connected as follows

Pin Label Arduino Connection
1 AO Analog input
2 G Ground (GND)
3 + 5 volt power
4 DO Digital input

So a quick and easy test is to write a sketch which outputs the digital and analog readings to the serial port and then see if we can get the readings to change

Code
[c]
// Arduino pin numbers
//D2 and A0 used
const int digital = 2;
const int analog = 0;

void setup()
{
pinMode(digital, INPUT);
Serial.begin(115200);
}

void loop()
{
Serial.print(digitalRead(digital));
Serial.print(“-“);
Serial.println(analogRead(analog));
delay(250);
}
[/c]
Now compile and upload this and open the serial monitor and set the baud rate to 115200 and you should see something like the following

 

touch serial monitor output

touch serial monitor output

As you can see there are 2 sets of readings

The 0 and 1023 is the reading when no touch is detected. The 1 and 113 is the reading when a touch is detected

Links

Here are links to the sensor kit

Ultimate 37 in 1 Sensor Modules Kit for Arduino from Amazon UK
Ultimate 37 in 1 Sensor Modules Kit for Arduino from Amazon US

Share
[lebox id="2"]

You may also like