i2c / TouchClamp

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
gabvoir
Posts: 7
Joined: 26 Jun 2017 21:34

i2c / TouchClamp

Post by gabvoir » 29 May 2018 23:21

Hi,

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;
}
Someone could help me ?

Thank you

FrenchyGab

Post Reply