Guest User

Untitled

a guest
Oct 17th, 2024
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <CapacitiveSensor.h>
  2. CapacitiveSensor capSensor = CapacitiveSensor(4, 2);
  3.  
  4. int threshold = 1000;
  5. const int ledPin = 12;
  6.  
  7. void setup() {
  8. Serial.begin(9600);
  9. pinMode(ledPin, OUTPUT);
  10. }
  11.  
  12. void loop() {
  13. long sensorValue = capSensor.capacitiveSensor(30);
  14. Serial.println(sensorValue);
  15.  
  16.  
  17. if (sensorValue > threshold) {
  18. digitalWrite(ledPin, HIGH);
  19. }
  20. else {
  21. digitalWrite(ledPin, LOW);
  22. }
  23.  
  24. delay(10);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment