Guest User

Untitled

a guest
Jun 23rd, 2020
132
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <ProTrinketKeyboard.h>
  2.  
  3. const int PIN_1 = 0;
  4. const int PIN_2 = 1;
  5. const int PIN_3 = 3;
  6. const int PIN_4 = 5;
  7. const int PIN_5 = 4;
  8. const int PIN_6 = 8;
  9. const int PIN_7 = 6;
  10.  
  11. const int MINRELEASETIME = 19;
  12.  
  13. void setup() {
  14.     pinMode(PIN_1, INPUT_PULLUP);
  15.     pinMode(PIN_2, INPUT_PULLUP);
  16.     pinMode(PIN_3, INPUT_PULLUP);
  17.     pinMode(PIN_4, INPUT_PULLUP);
  18.     pinMode(PIN_5, INPUT_PULLUP);
  19.     pinMode(PIN_6, INPUT_PULLUP);
  20.     pinMode(PIN_7, INPUT_PULLUP);
  21.  
  22.     TrinketKeyboard.begin();
  23. }
  24.  
  25. void loop() {
  26.     TrinketKeyboard.poll();
  27.  
  28.     if (digitalRead(PIN_1) == LOW) {
  29.         clear_keys();
  30.         TrinketKeyboard.pressKey(0, KEYCODE_F5); //run
  31.         end_keypress();
  32.        
  33.     } else if (digitalRead(PIN_2) == LOW) {
  34.         clear_keys();
  35.         TrinketKeyboard.pressKey(KEYCODE_MOD_LEFT_SHIFT, KEYCODE_F5); //stop debugging
  36.         end_keypress();
  37.        
  38.     } else if (digitalRead(PIN_3) == LOW) {
  39.         clear_keys();
  40.         TrinketKeyboard.pressKey(KEYCODE_MOD_LEFT_SHIFT | KEYCODE_MOD_LEFT_CONTROL, KEYCODE_F5); //restart debugging
  41.         end_keypress();
  42.        
  43.     } else if (digitalRead(PIN_4) == LOW) {
  44.         clear_keys();
  45.         TrinketKeyboard.pressKey(KEYCODE_MOD_LEFT_CONTROL, KEYCODE_B); //build
  46.         end_keypress();
  47.        
  48.     } else if (digitalRead(PIN_5) == LOW) {
  49.         clear_keys();
  50.         TrinketKeyboard.pressKey(0, KEYCODE_F10); //step over
  51.         end_keypress();
  52.        
  53.     } else if (digitalRead(PIN_6) == LOW) {
  54.         clear_keys();
  55.         TrinketKeyboard.pressKey(0, KEYCODE_F11); //step into
  56.         end_keypress();
  57.        
  58.     } else if (digitalRead(PIN_7) == LOW) {
  59.         clear_keys();
  60.         TrinketKeyboard.pressKey(KEYCODE_MOD_LEFT_SHIFT, KEYCODE_F11); //step out of
  61.         end_keypress();
  62.     }
  63.     delay(100);
  64. }
  65.  
  66. void wait() {
  67.     for (int i = 0; i < MINRELEASETIME/10; i++) {
  68.         delay(10);
  69.         TrinketKeyboard.poll();
  70.         return;
  71.     }
  72. }
  73. void clear_keys() {
  74.     TrinketKeyboard.pressKey(0, 0);
  75.     return;
  76. }
  77.  
  78. void end_keypress() {
  79.     clear_keys();
  80.     wait();
  81. }
RAW Paste Data