Learn interfacing Metal Touch Sensor Module KY-036 in Raspberry Pi. The metal Touch sensor is a type of switch which operates when touched by a conducting body. The touch sensor will generate certain output on touching metal spike of the sensor. Measured input from the Sensor is then fed to the amplifier. The amplifier sends data to output pins. In this, we are going to interface LED using the Metal Touch Sensor Module KY-036 in Raspberry Pi. So, let’s start.
Step 1: Required Components
Metal Touch Sensor Module x 1
Generic LED x 1
Breadboard x 1
Raspberry Pi x 1
Step 2: Circuit Time
These four pins in the Touch Sensor Module, VCC, GND, Analog output, Digital output. Connect VCC of the module to +5v of Raspberry Pi and GND of the module to the GND pin of Raspberry Pi. Then, connect the Digital output of the module to GPIO 13 of Raspberry Pi. Now, connect LED to GPIO 15 of Raspberry Pi.
Step 3: Code Time
This is code for Metal Touch Sensor Module KY-036 in Raspberry Pi. Firstly, initialize the LED pin and Touch pin and set GPIO to Board mode. Make the Touch pin as an input pin and an LED pin as an output pin. In the loop, if the touch pin is high then LED will turn on else it will turn off. Destroy is defined to clean up the GPIO pins to get precise output. In the main function, we have used exceptions. In try, the block loop will continuously run until the keyboard interrupt is provided. After keyboard interrupt, destroy function is executed and GPIO cleanup is performed.
Step 4: Run code to Raspberry Pi
Set the components as per the Circuit Diagram and run the above-given code in Raspberry Pi. LED will turn on if a metal spike is touched.
For running python code in Raspberry Pi, visit: raspberrypi.org/documentation/usage/python/
Learn basic hardware information of Raspberry Pi 3.
1 thought on “Interfacing Metal Touch Sensor Module KY-036 in Raspberry Pi”
if _name_ == ‘_main_’: # Program start from here
NameError: name ‘_name_’ is not defined