need some help with my project

I'm trying to make kind of HID keyboard with my arduino uno.

But I have problem with my switch and codes.

What I use for is always open switch(S.P.S.T-NO(1a)), which sends HIGH unless you push the switch.

First, my micro switch has kind of chattering. If I push micro switch it sends signal several times.

Even though I pushed only one time it sends over 10 signals.

Second, when I change firmware into keyboard-0.3.hex, it sends 'asdjkl' endlessly.

uint8_t buf[8] = {0}; //Keyboard report buffer #define PIN_a 13 #define PIN_s 12 #define PIN_d 11 #define L_Shift 10 #define PIN_j 9 #define PIN_k 8 #define PIN_l 7 #define R_Shift 6 void setup() { Serial.begin(9600); pinMode(PIN_a,INPUT); //a pinMode(PIN_s,INPUT); //s pinMode(PIN_d,INPUT); //d pinMode(L_Shift,INPUT); //L_Shift pinMode(PIN_j,INPUT); //j pinMode(PIN_k,INPUT); //k pinMode(PIN_l,INPUT); //l pinMode(R_Shift,INPUT); //R_Shift } void loop() { //a if (digitalRead(PIN_a) == LOW) { buf[2] = 4; Serial.write(buf, 8); Serial.println('a'); releaseKey(); } //s if (digitalRead(PIN_s) == LOW) { buf[2] = 22; Serial.write(buf, 8); releaseKey(); } //d if (digitalRead(PIN_d) == LOW) { buf[2] = 7; Serial.write(buf, 8); releaseKey(); } //L_Shift if (digitalRead(L_Shift) == LOW) { buf[2] = 225; Serial.write(buf, 8); releaseKey(); } //j if (digitalRead(PIN_j) == LOW) { buf[2] = 13; Serial.write(buf, 8); // Send keypress releaseKey(); } //k if (digitalRead(PIN_k) == LOW) { buf[2] = 14; Serial.write(buf, 8); // Send keypress releaseKey(); } //l if (digitalRead(PIN_l) == LOW) { buf[2] = 15; Serial.write(buf, 8); // Send keypress releaseKey(); } //R_Shift if (digitalRead(R_Shift) == LOW) { buf[2] = 229; Serial.write(buf, 8); // Send keypress releaseKey(); } } // Function for Key Release void releaseKey() { buf[0] = 0; buf[2] = 0; Serial.write(buf, 8); // Send Release key } 

got code frome here:https://www.instructables.com/How-to-Make-a-Arduino-HID-Keyboard/

Touch here for the full post on the Arduino Apprentices tumblr

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s