Skip to content

Instantly share code, notes, and snippets.

@minamiss
Created August 20, 2019 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minamiss/839012e158b0c747a2c0b209ec26b21f to your computer and use it in GitHub Desktop.
Save minamiss/839012e158b0c747a2c0b209ec26b21f to your computer and use it in GitHub Desktop.
#include <CapacitiveSensor.h>
int pin5=5;
int pin3=3;
CapacitiveSensor cs_3_2 = CapacitiveSensor(3,2);
void setup() {
cs_3_2.set_CS_AutocaL_Millis(0xFFFFFFFF);
Serial.begin(9600);
pinMode(pin5,OUTPUT);
pinMode(pin3,OUTPUT);
}
void loop() {
long start = millis();
long total1 = cs_3_2.capacitiveSensor(30);
Serial.println(total1);
digitalWrite(pin3,HIGH);
delay(5000);
digitalWrite(pin3,LOW);
delay(100);
if(total1>300){
digitalWrite(pin5,HIGH);
// digitalWrite(pin3,LOW);
delay(1000);
digitalWrite(pin5,LOW);
// digitalWrite(pin3,HIGH);
delay(100);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment