Advertisement
Guest User

Untitled

a guest
May 30th, 2022
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <MPR121.h>
  2. #include <Wire.h>
  3.  
  4. void setup() {
  5.   Serial.begin(9600);
  6.   Wire.begin();
  7.   MPR121.begin(0x5A));
  8.  
  9.   MPR121.setInterruptPin(2);
  10.   MPR121.setTouchThreshold(5);
  11.   MPR121.setReleaseThreshold(5);
  12.  
  13.   delay(1000);
  14. }
  15.  
  16. void loop() {
  17.   if (MPR121.touchStatusChanged()) {
  18.     MPR121.updateTouchData();
  19.     if (MPR121.isNewTouch(0)) {
  20.       Serial.println("Touch pin 0");
  21.     } else if (MPR121.isNewTouch(11)) {
  22.       Serial.println("Touch pin 11");
  23.     } else if (MPR121.isNewRelease(0)) {
  24.       Serial.println("Release pin 0");
  25.     } else if (MPR121.isNewRelease(11)) {
  26.       Serial.println("Release pin 11");
  27.     }
  28.   }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement