Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Keyboard.h>
- #define BUTTON_PIN_1 5 // Pin number for the first button
- #define BUTTON_PIN_2 8 // Pin number for the second button
- void setup() {
- Keyboard.begin();
- pinMode(BUTTON_PIN_1, INPUT_PULLUP);
- pinMode(BUTTON_PIN_2, INPUT_PULLUP);
- }
- void loop() {
- if (digitalRead(BUTTON_PIN_1) == LOW) {
- Keyboard.press('a'); // Press the 'a' key
- delay(150); // Adjust delay as needed
- Keyboard.release('a');
- delay(150); // Debounce delay
- }
- if (digitalRead(BUTTON_PIN_2) == LOW) {
- Keyboard.press('b'); // Press the 'b' key
- delay(150); // Adjust delay as needed
- Keyboard.release('b');
- delay(150); // Debounce delay
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment