Guest User

Untitled

a guest
Aug 14th, 2023
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <Keyboard.h>
  2.  
  3. #define BUTTON_PIN_1 5 // Pin number for the first button
  4. #define BUTTON_PIN_2 8 // Pin number for the second button
  5.  
  6. void setup() {
  7. Keyboard.begin();
  8. pinMode(BUTTON_PIN_1, INPUT_PULLUP);
  9. pinMode(BUTTON_PIN_2, INPUT_PULLUP);
  10. }
  11.  
  12. void loop() {
  13. if (digitalRead(BUTTON_PIN_1) == LOW) {
  14. Keyboard.press('a'); // Press the 'a' key
  15. delay(150); // Adjust delay as needed
  16. Keyboard.release('a');
  17. delay(150); // Debounce delay
  18. }
  19.  
  20. if (digitalRead(BUTTON_PIN_2) == LOW) {
  21. Keyboard.press('b'); // Press the 'b' key
  22. delay(150); // Adjust delay as needed
  23. Keyboard.release('b');
  24. delay(150); // Debounce delay
  25. }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment