PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

76 行
1.9KB

  1. /* PS2Keyboard library example
  2. PS2Keyboard now requries both pins specified for begin()
  3. keyboard.begin(data_pin, irq_pin);
  4. Valid irq pins:
  5. Arduino Uno: 2, 3
  6. Arduino Due: All pins, except 13 (LED)
  7. Arduino Mega: 2, 3, 18, 19, 20, 21
  8. Teensy 3.0: All pins, except 13 (LED)
  9. Teensy 2.0: 5, 6, 7, 8
  10. Teensy 1.0: 0, 1, 2, 3, 4, 6, 7, 16
  11. Teensy++ 2.0: 0, 1, 2, 3, 18, 19, 36, 37
  12. Teensy++ 1.0: 0, 1, 2, 3, 18, 19, 36, 37
  13. Sanguino: 2, 10, 11
  14. for more information you can read the original wiki in arduino.cc
  15. at http://www.arduino.cc/playground/Main/PS2Keyboard
  16. or http://www.pjrc.com/teensy/td_libs_PS2Keyboard.html
  17. Like the Original library and example this is under LGPL license.
  18. Modified by Cuninganreset@gmail.com on 2010-03-22
  19. Modified by Paul Stoffregen <paul@pjrc.com> June 2010
  20. */
  21. #include <PS2Keyboard.h>
  22. const int DataPin = 8;
  23. const int IRQpin = 5;
  24. PS2Keyboard keyboard;
  25. void setup() {
  26. delay(1000);
  27. keyboard.begin(DataPin, IRQpin);
  28. Serial.begin(9600);
  29. Serial.println("Keyboard Test:");
  30. }
  31. void loop() {
  32. if (keyboard.available()) {
  33. // read the next key
  34. char c = keyboard.read();
  35. // check for some of the special keys
  36. if (c == PS2_ENTER) {
  37. Serial.println();
  38. } else if (c == PS2_TAB) {
  39. Serial.print("[Tab]");
  40. } else if (c == PS2_ESC) {
  41. Serial.print("[ESC]");
  42. } else if (c == PS2_PAGEDOWN) {
  43. Serial.print("[PgDn]");
  44. } else if (c == PS2_PAGEUP) {
  45. Serial.print("[PgUp]");
  46. } else if (c == PS2_LEFTARROW) {
  47. Serial.print("[Left]");
  48. } else if (c == PS2_RIGHTARROW) {
  49. Serial.print("[Right]");
  50. } else if (c == PS2_UPARROW) {
  51. Serial.print("[Up]");
  52. } else if (c == PS2_DOWNARROW) {
  53. Serial.print("[Down]");
  54. } else if (c == PS2_DELETE) {
  55. Serial.print("[Del]");
  56. } else {
  57. // otherwise, just print all normal characters
  58. Serial.print(c);
  59. }
  60. }
  61. }