#include "captouch.h"
#define CAPTOUCH_DEBUG
int ledPin = D0;
//int touchSensor = A2
int hahaha=0;
CapTouch Touch(A2, A4);y
void setup(){
pinMode(ledPin, OUTPUT);
pinMode(A2, INPUT);
Touch.setup();
Serial.begin(9600);
Particle.variable("ledPin", &hahaha, INT);
}
void loop(){
checkForTouch();
Serial.print(hahaha);
}
int checkForTouch()
{
CapTouch::Event touchEvent = Touch.getEvent();
if (touchEvent == CapTouch::TouchEvent) {
digitalWrite(D0, HIGH); // LED
Particle.publish("motion-detected");
} else if (touchEvent == CapTouch::ReleaseEvent) {
digitalWrite(D0, LOW); // LED off
}}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .