I have a pretty simple installation project: i would like to create sort of a keyboard (multiple PushButtons) of which each key, when its pressed, send a data to Processing to tell it to launch a sound or a video or both in the room.
For now, my code is a modified "StateChangeDetection" sketch, where every pin is dedicated to a key.
Also, i would like to use the human body to close the circuit and allow arduino to send data to processing: The naked feet on a metal board, the hand would slide on multiple conductive ink drawings. But here is the problem: in my circuit's actual state, the human body isn't equal at all to a classic pushbutton: the current don't seems to pass in my body.
Okay i’ve mounted a circuit using the capsens library, but it’s not doing so well. It may be because of my code, or because of my circuit and the evident instability of the sensors which are interfering together.
Could somebody take a look to this code, and tell me how i could improve it ? By reducing its size using arrays for example (which i don’t know how to do)
#include <CapacitiveSensor.h>
CapacitiveSensor cs_4_3 = CapacitiveSensor(4,3);
CapacitiveSensor cs_4_5 = CapacitiveSensor(4,5);
CapacitiveSensor cs_4_6 = CapacitiveSensor(4,6);
CapacitiveSensor cs_4_7 = CapacitiveSensor(4,7);
CapacitiveSensor cs_4_8 = CapacitiveSensor(4,8);
CapacitiveSensor cs_4_9 = CapacitiveSensor(4,9);
CapacitiveSensor cs_4_10 = CapacitiveSensor(4,10);
CapacitiveSensor cs_4_11 = CapacitiveSensor(4,11);
CapacitiveSensor cs_4_12 = CapacitiveSensor(4,12);
CapacitiveSensor cs_4_13 = CapacitiveSensor(4,13); // 10 pins
void setup()
{
cs_4_3.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example
Serial.begin(9600);
}
void loop()
{
long total3 = cs_4_3.capacitiveSensor(30);
long total5 = cs_4_5.capacitiveSensor(30);
long total6 = cs_4_6.capacitiveSensor(30);
long total7 = cs_4_7.capacitiveSensor(30);
long total8 = cs_4_8.capacitiveSensor(30);
long total9 = cs_4_9.capacitiveSensor(30);
long total10 = cs_4_10.capacitiveSensor(30);
long total11 = cs_4_11.capacitiveSensor(30);
long total12 = cs_4_12.capacitiveSensor(30);
long total13 = cs_4_13.capacitiveSensor(30);
if(total3 >50) {
Serial.print(1);
}
if(total5 >50) {
Serial.print(2);
}
if(total6 >50) {
Serial.print(3);
}
if(total7 >50) {
Serial.print(4);
}
if(total8 >50) {
Serial.print(5);
}
if(total9 >50) {
Serial.print(6);
}
if(total10 >50) {
Serial.print(7);
}
if(total11 >50) {
Serial.print(8);
}
if(total12 >50) {
Serial.print(9);
}
if(total13 >50) {
Serial.print(10);
}
delay(10);
}
Paul__B:
I second that, but not using the Capsense library - I have not had much luck with that.
This seems like a good solution also, but i would like my buttons to be quite large and extended, and not this small. But maybe starting from this little sensor i can make a large and unorthodox size button?
Hillcres-Hellio:
This seems like a good solution also, but I would like my buttons to be quite large and extended, and not this small. But maybe starting from this little sensor I can make a large and unorthodox size button?
If you note the "thru" to the left of and below the "TOUCH" circle, it corresponds to the bottom right pad on the other side. You connect that - by as short a wire as possible - to your touch pad. The obvious thing is to mount this little board under each of your larger touch pads.
I understand that it calibrates itself to the size of the pad on switch-on, and thereafter detects touch or indeed, close proximity. The latter is for what I want them.