Advertisement
Guest User

Teensy USB Device.sketch

a guest
Oct 22nd, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. #include <keyboard.h>
  2.  
  3. //Pin layout here
  4. const int buttonPin = 0;
  5. const int buttonPin2 = 1;
  6. const int buttonPin3 = 2;
  7. const int buttonPin4 = 3;
  8. const int buttonPin5 = 4;
  9. const int buttonPin6 = 5;
  10.  
  11. int buttonState = 0;
  12. int buttonState2 = 0;
  13. int buttonState3 = 0;
  14. int buttonState4 = 0;
  15. int buttonState5 = 0;
  16. int buttonState6 = 0;
  17.  
  18. //LED light
  19. int led = 11;
  20.  
  21. void setup(){
  22. pinMode(buttonPin, INPUT_PULLUP);
  23. pinMode(buttonPin2, INPUT_PULLUP);
  24. pinMode(buttonPin3, INPUT_PULLUP);
  25. pinMode(buttonPin4, INPUT_PULLUP);
  26. pinMode(buttonPin5, INPUT_PULLUP);
  27. pinMode(buttonPin6, INPUT_PULLUP);
  28. pinMode(led, OUTPUT);
  29. }
  30.  
  31. void loop(){
  32. //this is the led light control
  33. digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
  34. delay(300); // wait for a second
  35. digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
  36. delay(100);
  37.  
  38. buttonState = digitalRead(buttonPin);
  39. buttonState2 = digitalRead(buttonPin2);
  40. buttonState3 = digitalRead(buttonPin3);
  41. buttonState4 = digitalRead(buttonPin4);
  42. buttonState5 = digitalRead(buttonPin5);
  43. buttonState6 = digitalRead(buttonPin6);
  44.  
  45. //this is for Save As...
  46. if (buttonState == LOW){
  47. Keyboard.set_modifier(MODIFIERKEY_CTRL);
  48. Keyboard.send_now();
  49. Keyboard.set_modifier(MODIFIERKEY_CTRL | MODIFIERKEY_SHIFT);
  50. Keyboard.send_now();
  51. Keyboard.set_key1(KEY_S);
  52. Keyboard.send_now();
  53. }
  54. if (buttonState == HIGH){
  55. Keyboard.set_modifier(0);
  56. Keyboard.set_key1(0);
  57. Keyboard.send_now();
  58. }
  59. //This will be for Brush Tool [B]
  60. if (buttonState2 == LOW){
  61. Keyboard.set_key2(KEY_B);
  62. Keyboard.send_now();
  63. }
  64. if (buttonState2 == HIGH){
  65. Keyboard.set_key2(0);
  66. Keyboard.send_now();
  67. }
  68. // Eraser Tool [E]
  69. if (buttonState3 == LOW){
  70. Keyboard.set_key3(KEY_E);
  71. Keyboard.send_now();
  72. }
  73. if (buttonState3 == HIGH){
  74. Keyboard.set_key3(0);
  75. Keyboard.send_now();
  76. }
  77. //Hand Tool
  78. if (buttonState4 == LOW){
  79. Keyboard.set_key4(KEY_SPACE);
  80. Keyboard.send_now();
  81. }
  82. if (buttonState4 == HIGH){
  83. Keyboard.set_key4(0);
  84. Keyboard.send_now();
  85. }
  86. if (buttonState5 == LOW){
  87. Keyboard.set_key5(KEY_H);
  88. Keyboard.send_now();
  89. }
  90. if (buttonState5 == HIGH){
  91. Keyboard.set_key5(0);
  92. Keyboard.send_now();
  93. }
  94. if (buttonState6 == LOW){
  95. //Undo Command
  96. Keyboard.set_modifier(MODIFIERKEY_CTRL);
  97. Keyboard.send_now();
  98. //Keyboard.set_modifier(MODIFIERKEY_CTRL | MODIFIERKEY_SHIFT);
  99. //Keyboard.send_now();
  100. Keyboard.set_key6(KEY_Z);
  101. Keyboard.send_now();
  102. }
  103. if (buttonState6 == HIGH){
  104. Keyboard.set_modifier(0);
  105. Keyboard.set_key6(0);
  106. Keyboard.send_now();
  107. }
  108. delay(2);
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement