Вернуться на страницу библиотеки модулей
/*
* KY-036 Metal Touch Sensor (HW-494) — Arduino example
* Reads the digital output (D0) to toggle the on-board LED, and prints
* the analog output (A0) to the Serial Monitor / Plotter. Touching the
* metal pin drives D0 HIGH and changes the analog reading.
* Guide: https://arduinomodules.info/ky-036-metal-touch-sensor-module/
*/
int digitalPin = 7; // KY-036 digital interface
int analogPin = A0; // KY-036 analog interface
int ledPin = 13; // Arduino LED pin
int digitalVal; // digital readings
int analogVal; // analog readings
void setup()
{
pinMode(digitalPin, INPUT);
pinMode(analogPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
// Read the digital interface
digitalVal = digitalRead(digitalPin);
if (digitalVal == HIGH)
{
digitalWrite(ledPin, HIGH); // Turn ON Arduino's LED
}
else
{
digitalWrite(ledPin, LOW); // Turn OFF Arduino's LED
}
// Read analog interface
analogVal = analogRead(analogPin);
Serial.println(analogVal); // Print analog value to serial
delay(100);
}
Рекомендуемые ссылки:
Arduino Metal Touch Sensor KY-036 (HW-494) — Pinout, Wiring & Code
KY-036 Metal Touch Sensor Module : 4 Steps – Instructables
KY-036 Metal-touch sensor – SensorKit
Project 22: Metal Touch Sensor — keyestudio WiKi documentation
ESP32 KY-036 Metal Touch Sensor Module Pinout & Datasheet
Arduino – Touch Sensor Switch Using The KY-036 – Hackster.io