hello everybody!
I m new with Arduino, and I have a question
seeing the example about Native Capacitive Sensor (Arduino Playground - CapacitiveSensor) I would like to know the following.
What would be the maximum recommended length for a cable operating as touch-sensitive input? 10 meters would be fine?
no 10 meters of shielded cable would swamp out the signal from the sensor. You could however use a Pro Mini as a local sensor and return the signal on the same cable that supplies power to the Pro-Mini.
That wouldn't be too difficult.
Anyway,
I tried to use it with a 10 meter cable ( telephone cable, 0.12mm) and it worked fine
When I touch the cable end with a metal (or my fingers), I get a response on the serial port. Response is low but enough for me.
This is the Arduino code, Any suggestions?
thanks and cheers,
Y.
// sensor key
// code adapted from: http://arduino.cc/forum/index.php/topic,42592.0.html
#define KEYPORT PORTB
#define KEYDDR DDRB
#define KEYPIN PINB
#define KEY0 PB0 // capture input - digital 8
void setup()
{
Serial.begin(9600); // connect to the serial port
}
// returns capacity on one input pin
// pin must be the bitmask for the pin e.g. (1<<PB0)
char getcap(char pin)
{
char i = 0;
KEYDDR &= ~pin; // input
KEYPORT |= pin; // pullup on
for(i = 0; i < 16; i++)
if( (KEYPIN & pin) ) break;
KEYPORT &= ~pin; // low level
KEYDDR |= pin; // discharge
return i;
}
void loop ()
{
char capval;
char pinval= {1<<KEY0}; // digital 8
capval = getcap(pinval);
if (capval>1){
Serial.println(capval, DEC);
}
delay(1);
}