Touch Sensor Module w/ M2 Mount
- Was RM17.00
-
RM3.00
- Product Code: Touch Sensor Module
- Availability: In Stock
Features
Specifications
This is a real simple set up.
You will know that you have power properly applied when the green LED is on.
Copy, Paste and Upload the Arduino Sketch
The sketch below provides an output to your serial monitor indicating whether or not the sensor is pressed.
// Capacitive Touch Sensor Tutorial // When Sig Output is high, touch sensor is being pressed #define ctsPin 2 // Pin for capactitive touch sensor int ledPin = 13; // pin for the LED void setup() { Serial.begin(9600); pinMode(ledPin, OUTPUT); pinMode(ctsPin, INPUT); } void loop() { int ctsValue = digitalRead(ctsPin); if (ctsValue == HIGH){ digitalWrite(ledPin, HIGH); Serial.println("TOUCHED"); } else{ digitalWrite(ledPin,LOW); Serial.println("not touched"); } delay(500); }
Once you’ve uploaded the sketch, open your serial monitor. Touch the sensor pad while looking at the monitor. You should see an output that looks something like the picture below.