I can see a big jump in the serial monitor outputs over 10k when i touch copper and when i dont touch it it reads between 200 - 300.
I am a big time beginner at this.
I need a key press sent to my computer as if acting like a keyboard when I touch the copper. I guess it would be the same if the serial monitor is over 10k then print F? I'm not sure if that is the correct phrasing.
chuco61:
I guess it would be the same if the serial monitor is over 10k then print F?
A common mistake.
What you need is to send an F when the input changes from low to high (or high to low, depending on when you want the keypress to register). To do this, you need to "remember" what the input was last time you looked at it.
Is it similar to this code that I have used for another project? Here i used the Leonardo and arcade buttons. This I can read and understand for the most part. I am just having difficulty merging the capacitive sensor and the keyboard.
void setup() {
// make pin 2 an input and turn on the
// pullup resistor so it goes high unless
// connected to ground:
pinMode(2, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
Keyboard.begin();
}
void loop() {
//if the button is pressed
if(digitalRead(2)==LOW){
//Send an ASCII '1',
Keyboard.press('1');
delay(125);
Keyboard.release('1');
delay(100);
}
//if the button is pressed
if(digitalRead(4)==LOW){
//Send an ASCII '3',
Keyboard.press('3');
delay(125);
Keyboard.release('3');
delay(100);
}
//if the button is pressed
if(digitalRead(6)==LOW){
//Send an ASCII '4',
Keyboard.press('4');
delay(125);
Keyboard.release('4');
delay(100);
}
//if the button is pressed
if(digitalRead(8)==LOW){
//Send an ASCII '6',
Keyboard.press('6');
delay(125);
Keyboard.release('6');
delay(100);
}
//if the button is pressed
if(digitalRead(10)==LOW){
//Send an ASCII '7',
Keyboard.press('7');
delay(125);
Keyboard.release('7');
delay(100);
}
//if the button is pressed
if(digitalRead(12)==LOW){
//Send an ASCII '9',
Keyboard.press('9');
delay(125);
Keyboard.release('9');
delay(100);
}
}
I am just having difficulty merging the capacitive sensor and the keyboard.
Because you are not trying. You've made NO attempt that we can see.
You have a current value. You need to have a previous value. That is dirt simple - two lines of code - one to define the variable and one to set it to the current value at the end of loop().
You need to compare the current value to to the previous value, to see if the change is significant. That is dirt simple - one line of code.
You need to take some action if the change is significant. That's two more lines for the curly braces after the if statement and up to three lines in the braces to press, delay, and release the key.