I would like to use a TouchClamp click board from MikroElektronika https://www.mikroe.com/touchclamp-click.
I've find a tutorial based on Arduino https://electronza.com/chipkit-vs1053-t ... p-drums/2/.
Unfortunately when I apply to z-uno, it have unpredictable behaviour and i can't communicate by serial.
I've to go to rescue mode to communicate.
Here my code :
Code: Select all
#include "Adafruit_MPR121.h"
Adafruit_MPR121 cap;
uint16_t lasttouched = 0;
uint16_t currtouched = 0;
void setup() {
Serial.begin(9600);
Serial.println("Adafruit MPR121 Capacitive Touch sensor test");
if (!cap.begin(0x5A)) {
Serial.println("MPR121 not found, check wiring?");
while (1);
}
Serial.println("MPR121 found!");
}
void loop() {
currtouched = cap.touched();
Serial.print("test");
for (uint8_t i=0; i<12; i++) {
// it if *is* touched and *wasnt* touched before, alert!
if ((currtouched & _BV(i)) && !(lasttouched & _BV(i)) ) {
Serial.print(i); Serial.println(" touched");
delay(5);
}
// if it *was* touched and now *isnt*, alert!
if (!(currtouched & _BV(i)) && (lasttouched & _BV(i)) ) {
Serial.print(i); Serial.println(" released");
}
}
lasttouched = currtouched;
}
Thank you
FrenchyGab