Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

UsbKeyboardDemo1.pde 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include "UsbKeyboard.h"
  2. #define BUTTON_PIN 12
  3. // If the timer isr is corrected
  4. // to not take so long change this to 0.
  5. #define BYPASS_TIMER_ISR 1
  6. void setup() {
  7. pinMode(BUTTON_PIN, INPUT);
  8. digitalWrite(BUTTON_PIN, HIGH);
  9. #if BYPASS_TIMER_ISR
  10. // disable timer 0 overflow interrupt (used for millis)
  11. TIMSK0&=!(1<<TOIE0); // ++
  12. #endif
  13. }
  14. #if BYPASS_TIMER_ISR
  15. void delayMs(unsigned int ms) {
  16. /*
  17. */
  18. for (int i = 0; i < ms; i++) {
  19. delayMicroseconds(1000);
  20. }
  21. }
  22. #endif
  23. void loop() {
  24. UsbKeyboard.update();
  25. digitalWrite(13, !digitalRead(13));
  26. if (digitalRead(BUTTON_PIN) == 0) {
  27. //UsbKeyboard.sendKeyStroke(KEY_B, MOD_GUI_LEFT);
  28. UsbKeyboard.sendKeyStroke(KEY_H);
  29. UsbKeyboard.sendKeyStroke(KEY_E);
  30. UsbKeyboard.sendKeyStroke(KEY_L);
  31. UsbKeyboard.sendKeyStroke(KEY_L);
  32. UsbKeyboard.sendKeyStroke(KEY_O);
  33. UsbKeyboard.sendKeyStroke(KEY_SPACE);
  34. UsbKeyboard.sendKeyStroke(KEY_W);
  35. UsbKeyboard.sendKeyStroke(KEY_O);
  36. UsbKeyboard.sendKeyStroke(KEY_R);
  37. UsbKeyboard.sendKeyStroke(KEY_L);
  38. UsbKeyboard.sendKeyStroke(KEY_D);
  39. //UsbKeyboard.sendKeyStroke(KEY_B, MOD_GUI_LEFT);
  40. UsbKeyboard.sendKeyStroke(KEY_ENTER);
  41. #if BYPASS_TIMER_ISR // check if timer isr fixed.
  42. delayMs(20);
  43. #else
  44. delay(20);
  45. #endif
  46. }
  47. }