Penguin as HID Bluetooth Keyboard (2012)
Using Sparkfun’s Bluetooth Modem – BlueSMiRF HID to interface between an Arduino Pro Mini and a desktop Computer. Also see: Arduino as Bluetooth Keyboard post >> http://www.kobakant.at/DIY/?p=3310
Setup Instructions
Program Arduino
Upload the following code to the Penguin Arduino. The code has been simplified for demo purposes.
Arduino HID Penguin Code >> https://github.com/plusea/Penguin-Interface/blob/master/code/a_penguin_HID/a_penguin_HID.pde
Key commands:
Squeeze or hug penguin body –> “Enter Key” – each squeeze is one key press – set sensor thresholds in code
Tilt upright –> Neutral position
Tilt back –> “Down Arrow” – repeats key press every X seconds, default to 0.5 sec – set timing in code
Tilt right –> “Right Arrow” – repeats key press every X seconds, default to 0.5 sec – set timing in code
Tilt left –> “Left Arrow” – repeats key press every X seconds, default to 0.5 sec – set timing in code
Squeeze or bend both wings –> “Up Arrow” – repeats key press every X seconds, default to 0.5 sec – set sensor thresholds and timing in code
Simulated output:
Squeeze or hug penguin body –> vibrate motor – set sensor thresholds in code
Squeeze or bend right wing only –> when pressured toggle between red, green, blue and white LED light, when released turn light off – set sensor thresholds in code
Squeeze or bend left wing only –> play melody – set sensor thresholds in code
Connect HID Bluetooth Modem to Arduino with Adaptor
BlueSMiRF HID >> Arduino Mini:
RTS >> GRN = CTS
RX >> TX
TX >> RX
VCC >> VCC
CTS >> GND
GND >> BLK = GND
Make a simple adapter:
Pair with Bluetooth Device
Pairing Bluetooth device on Mac >> http://www.rioleo.org/setting-up-the-arduino-pro-mini-and-bluetooth-mate-on-mac.php
Pairing Bluetooth device on Windows >> http://jondontdoit.blogspot.com/2011/11/bluetooth-mate-tutorial.html
Steps:
– power your circuit and the light on your Bluetooth modem should blink red
– open the Bluetooth preferences of your computer and opt to pair with a new Bluetooth device by pressing the “+” at the bottom of the Bluetooth device list
– the circuit should show up as a FireFly Bluetooth device with an address similar to this: FireFly-A229
– press continue to begin pairing process
– when the attempt to pair with the device fails, opt to connect with pass code by pressing the Passcode Options button at the bottom left of the window
– type “1234”, which is the generic pass code
– once successfully paired the light on your BlueSmirf Modem should turn a steady green
– the first time i paired the FireFly modem with my computer it tried to identify it as a keyboard and was asking me to press the button next to the shift key. since this was not possible to do on the modem, i instead pressed a random button on my real (other) keyboard, which it didn’t recognize and then let me skip the step and manually input the type of keyboard i wanted the module to be recognized as
– the Bluetooth module should now show up as follows in your Bluetooth device list:
Re-Connecting
When i disconnect the Bluetooth modem from the power, my computer does not automatically re-connect to it when i re-power it.
I have to go back into the Bluetooth preferences and opt to add a new device, then select “Okay” when asked “Your computer is already paired with that device. Do you wish to remove the pairing and setup the device again?”
Next Steps…
How does the computer SEND commands TO the Penguin?
The Bluetooth modem needs to switch back and forth between an HID device and a device with a serial port connection (SPP mode). For this to happen the Arduino needs to put the Bluetooth modem into command mode ($$$) and send the following commands:
$$$ = command mode
S~,0 = enables SPP protocol
R,1 = reboot using SPP
$$$ S~,0 R,1
$$$ = command mode
S~,6 = enables HID protocol
R,1 = reboot using HID
$$$ S~,6 R,1