]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/examples/PSBuzz/PSBuzz.ino
lufa: usb-usb: Use LUFA startup instead of cusotom
[max/tmk_keyboard.git] / tmk_core / protocol / usb_hid / USB_Host_Shield_2.0 / examples / PSBuzz / PSBuzz.ino
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:  kristianl@tkjelectronics.com
5  */
6
7 #include <PSBuzz.h>
8
9 // Satisfy the IDE, which needs to see the include statment in the ino too.
10 #ifdef dobogusinclude
11 #include <spi4teensy3.h>
12 #include <SPI.h>
13 #endif
14
15 USB Usb;
16 PSBuzz Buzz(&Usb);
17
18 void setup() {
19   Serial.begin(115200);
20 #if !defined(__MIPSEL__)
21   while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
22 #endif
23   if (Usb.Init() == -1) {
24     Serial.print(F("\r\nOSC did not start"));
25     while (1); // Halt
26   }
27   Serial.println(F("\r\nPS Buzz Library Started"));
28 }
29
30 void loop() {
31   Usb.Task();
32
33   if (Buzz.connected()) {
34     for (uint8_t i = 0; i < 4; i++) {
35       if (Buzz.getButtonClick(RED, i)) {
36         Buzz.setLedToggle(i); // Toggle the LED
37         Serial.println(F("RED"));
38       }
39       if (Buzz.getButtonClick(YELLOW, i))
40         Serial.println(F("YELLOW"));
41       if (Buzz.getButtonClick(GREEN, i))
42         Serial.println(F("GREEN"));
43       if (Buzz.getButtonClick(ORANGE, i))
44         Serial.println(F("ORANGE"));
45       if (Buzz.getButtonClick(BLUE, i))
46         Serial.println(F("BLUE"));
47     }
48   }
49 }