Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PSBuzz.ino 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. Example sketch for the Playstation Buzz library - developed by Kristian Lauszus
  3. For more information visit my blog: http://blog.tkjelectronics.dk/ or
  4. send me an e-mail: [email protected]
  5. */
  6. #include <PSBuzz.h>
  7. // Satisfy the IDE, which needs to see the include statment in the ino too.
  8. #ifdef dobogusinclude
  9. #include <spi4teensy3.h>
  10. #include <SPI.h>
  11. #endif
  12. USB Usb;
  13. PSBuzz Buzz(&Usb);
  14. void setup() {
  15. Serial.begin(115200);
  16. #if !defined(__MIPSEL__)
  17. while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
  18. #endif
  19. if (Usb.Init() == -1) {
  20. Serial.print(F("\r\nOSC did not start"));
  21. while (1); // Halt
  22. }
  23. Serial.println(F("\r\nPS Buzz Library Started"));
  24. }
  25. void loop() {
  26. Usb.Task();
  27. if (Buzz.connected()) {
  28. for (uint8_t i = 0; i < 4; i++) {
  29. if (Buzz.getButtonClick(RED, i)) {
  30. Buzz.setLedToggle(i); // Toggle the LED
  31. Serial.println(F("RED"));
  32. }
  33. if (Buzz.getButtonClick(YELLOW, i))
  34. Serial.println(F("YELLOW"));
  35. if (Buzz.getButtonClick(GREEN, i))
  36. Serial.println(F("GREEN"));
  37. if (Buzz.getButtonClick(ORANGE, i))
  38. Serial.println(F("ORANGE"));
  39. if (Buzz.getButtonClick(BLUE, i))
  40. Serial.println(F("BLUE"));
  41. }
  42. }
  43. }