Sunday, April 15, 2018

Carpc project - custom USB keyboard

I recently uploaded a new video to show my custom-made carpc based on a Raspberry Pi. In the video, I had to leave a lot of information out for the sake of runtime, so, I decided to write a little series of posts to explore thoughts and ideas about this project.

This episode is about the custom keyboard.

Disclaimer (sort of):
Be aware that this post is not self-contained. If you haven't seen the video, you probably won't get much out of this reading. Also, this is not a tutorial on how to build a carpc like the one I made. For that, I'd need much more time and space. I just want to document the thought process behind a few hardware and software choices, share some techno-ramblings, and provide you with some links to get you started using the components I used.

Have you ever modified your car with custom electronics? Are you planning to hack a Raspberry Pi into a device that was not intended to be modified? Have you ever started a simple project (such as adding music to your car), and somehow turned it into a huge, titanic undertaking?

Custom USB keyboard

My custom USB keyboard.
A carpc is certainly cool, but as soon as you make something with a touchscreen, you face the eternal conundrum of buttonless designs: how do I use it, if I can't look at it? I'm sure you've faced the same problem once or twice, trying to operate your smartphone without looking at it. It's not easy, and when you are driving, it's not safe either.

My first instinct was to buy a small USB keyboard, maybe wireless, and tuck it somewhere behind the steering wheel. Unfortunately, the designers of my car were not forward-looking enough, and did not leave enough space anywhere around the steering wheel. Such a bad design....

Anyway, every time I face a "this is impossible" situation, my reaction is always "then, I'll make my own". So, I decided to design my own USB keyboard to fit in the little sleeve of space behind my steering wheel.

Adafruit Pro Trinket.
The main constraint of the design was space, so I had to reduce the number of keys to the bare minimum (12, to be precise). The keyboard design is based on a Pro Trinket microcontroller board from Adafruit (It's a sort of compact Arduino-compatible development board). On their website, they provide a nice Arduino program to configure the Trinket as a USB keyboard, and use momentary push buttons connected to the Trinket's GPIOs as the keys. What I had to do, is to associate each button press to a standard key code to be transmitted to the Pi, and fool it into thinking it is talking to a real USB keyboard. In addition to that, I wired a PSP thumb joystick to two analog inputs of the Trinket, and mapped the ADC readings to the four directional arrows.

This allowed me to build a tiny custom USB keyboard to be installed behind my steering wheel.

The keyboard provides all basic buttons needed to control the media centre software installed on the carpc. The only notable exception is volume control. I decided that the carpc will always operate at full blast, and I will control the final volume on the car radio directly, using either the buttons on the radio, or the "factory" steering wheel control stick.

Or keep it at full blast.

Have fun,
Kradion.

2 comments:

  1. Hi kradion, Good project, As you shema and the code for the connection and its connection to the raspberry
    Thank you for your answer
    Madlab

    ReplyDelete
    Replies
    1. For the keys, I followed the Adafruit tutorial on https://learn.adafruit.com/pro-trinket-keyboard and simply added more keys. The thumb joystick is connected to the analog inputs of the Trinket, and each direction is encoded as one of the four directional arrow keys. I started from here: https://learn.adafruit.com/pro-trinket-usb-hid-mouse/

      Delete

Featured posts

Raspberry Pi Bluetooth speakers