Connecting a basic Touch sensor

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

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


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

void setup()
pinMode(digital, INPUT);

void loop()

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


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


Comments are closed.