I’m just starting to dabble in Arduino so I’m testing a program that emulates a keyboard and will type a message when a button is shorted. However. Touching anything to the pins (a wire, a button, my finger) will trigger the input repeatedly. I have tried definign the pin on a non-QTouch pin, same result.
My sketch below if relevant.
#include <Keyboard.h>
const int buttonPin = 2;
int previousButtonState = HIGH;
void setup() {
pinMode(buttonPin, INPUT);
Keyboard.begin();
}
void loop() {
int currentButtonState = digitalRead(buttonPin);
if (currentButtonState == LOW && previousButtonState == HIGH) {
Keyboard.print("I am a button!");
}
previousButtonState = currentButtonState;
delay(10);