Teensy as a keyboard

Status
Not open for further replies.

jumbodrawn

New member
Hi!
I want to hook up 4-5 buttons and use them as a keypad type device with the teensy. I want to be able to set them to commands like media keys, but if not numbers should work. I did some research, and somebody said that this library thing is good for what I want:

https://github.com/tmk/tmk_keyboard/blob/master/README.md

Any suggestions on how to do it?

Specifically, what commands should I use, and do I just load the library into the Arduino code?
I've never actually used the teensy, but I'm pretty sure you just make your program, then somehow export it as a hex file then use the teensy loader?
 
You don't need any external library to accomplish that.
The USB HID support of the Teensy core libraries already support key modifiers like the media keys you need.

There is one page explaining the keyboard functionality in Teensy:
http://pjrc.com/teensy/td_keyboard.html

You can find the full set of codes in Teensyduino:
hardware/teensy/avr/cores/teensy3/keylayouts.h
hardware/teensy/avr/cores/teensy/keylayouts.h

From there:
#define KEY_MEDIA_VOLUME_INC 0x01
#define KEY_MEDIA_VOLUME_DEC 0x02
#define KEY_MEDIA_MUTE 0x04
#define KEY_MEDIA_PLAY_PAUSE 0x08
#define KEY_MEDIA_NEXT_TRACK 0x10
#define KEY_MEDIA_PREV_TRACK 0x20
#define KEY_MEDIA_STOP 0x40
#define KEY_MEDIA_EJECT 0x80

Hope it's what you need.
 
You should install Teensyduino, and then in Arduino look at File > Examples > Teensy > USB_Keyboard > Buttons.

The media keys in Teensyduino work great with Mac and Linux, but unfortunately they're not compatible with Windows.
 
You don't need any external library to accomplish that.
The USB HID support of the Teensy core libraries already support key modifiers like the media keys you need.

There is one page explaining the keyboard functionality in Teensy:
http://pjrc.com/teensy/td_keyboard.html

You can find the full set of codes in Teensyduino:
hardware/teensy/avr/cores/teensy3/keylayouts.h
hardware/teensy/avr/cores/teensy/keylayouts.h

From there:
#define KEY_MEDIA_VOLUME_INC 0x01
#define KEY_MEDIA_VOLUME_DEC 0x02
#define KEY_MEDIA_MUTE 0x04
#define KEY_MEDIA_PLAY_PAUSE 0x08
#define KEY_MEDIA_NEXT_TRACK 0x10
#define KEY_MEDIA_PREV_TRACK 0x20
#define KEY_MEDIA_STOP 0x40
#define KEY_MEDIA_EJECT 0x80

Hope it's what you need.

Thanks for the quick response! I plan to use the Arduino IDE, and I know that the command would be keyboard.write(' '). How would I put in the media keys? Would I do keyboard.write('KEY_MEDIA_VOLUME_UP ') or keyboard.write('0x01')?
Also I might use a Pro Micro instead, would the commands still be the same?
Am I missing something?
 
You should install Teensyduino, and then in Arduino look at File > Examples > Teensy > USB_Keyboard > Buttons.

The media keys in Teensyduino work great with Mac and Linux, but unfortunately they're not compatible with Windows.


Does this mean that I won't be able to make volume up and down buttons with my PC?
How would real keyboards have volume buttons then?
Would it work any differently with a pro micro?
 
Status
Not open for further replies.
Back
Top