Iss it possible to get an arduino code for Grove - I2C Touch Sensor SKU 101020047? (The sample code given is Codecraft). In addition, how can I buy more Touch Feeler?
Hi,
attaching example sketch, please check it out and let me know.
fist add the library into Arduino IDE and try the example sketch (library link: I2c_touch_sensor.zip )
i2c_touch.ino
[code]
#include <Wire.h> // include I2C library
#include <i2c_touch_sensor.h>
#include <MPR121.h>
i2ctouchsensor touchsensor; // keep track of 4 pads’ states
//boolean padTouched[4];
long previousMillis = 0;
long interval = 100;
void setup()
{
Serial.begin(9600); // for debugging
Serial.print(“begin to init”);
Wire.begin(); // needed by the GroveMultiTouch lib
touchsensor.initialize(); // initialize the feelers // initialize the containers
//for(int i=0; i<=3; i++)
//{
// padTouched[i]=false;
//}
}
void loop()
{
unsigned char MPR_Query=0;
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval)
{
previousMillis = currentMillis;
touchsensor.getTouchState();
}
for (int i=0;i<12;i++)
{
if (touchsensor.touched&(1<<i))
{
Serial.print(“pin “);
Serial.print(i);
Serial.println(” was touched”);
}
}
}
[/code]