External control/interface - what to look for and where to start

7 posts
by IMG » Tue Feb 14, 2012 9:04 am
I have a project in mind for an R-Pi and though I'm familiar with Linux, software programming, etc., what I want to do is to be able to control the device using things like a rotary encoder (e.g. to change volume or step through lists/options) and push buttons — this is something I don't know anything about.

I understand it means some kind of external interface, like the Gertboard (?), but please throw some buzzwords at me, or tell me where to start with info for this kind of programming!
Posts: 6
Joined: Tue Feb 14, 2012 8:56 am
by Lynbarn » Tue Feb 14, 2012 9:19 am
Hi IMG, and welcome,

If you go to the home page and use the Google search box (the search facility within the forum isn't particularly good, but may also help), you may be able to find similar projects being discussed. One thread that you may find a useful starting point is HERE
Posts: 464
Joined: Wed Jan 04, 2012 11:03 pm
by IMG » Tue Feb 14, 2012 9:23 am
Thanks, yes, a search for 'rotary encoder' turned up nothing...
Posts: 6
Joined: Tue Feb 14, 2012 8:56 am
by Rokys » Tue Feb 14, 2012 12:09 pm
Your best option (IMHO) is the keyboard hack commonly used to build homemade controls for gaming. Get a cheap and/or old usb keyboard, dissassemble it, keeping only the encoder board (and usb cable obviously).

After stripping it, it's easy to plug it to a computer, and map its matrix.

Google "homemade arcade controls" and that should get you started.
Posts: 1
Joined: Tue Feb 14, 2012 11:24 am
by IMG » Tue Feb 14, 2012 12:58 pm
Aha! That is genius, thanks!
Posts: 6
Joined: Tue Feb 14, 2012 8:56 am
by bredman » Tue Feb 14, 2012 6:35 pm
If you want it really simple...

Get a USB mouse with a scrollwheel. Take it apart.

Inside, you will find two switches which are mapped via USB to "left-click" and "right-click". You will also find a rotary encoder which mapped via USB to "scroll-up" and "scroll-down".

This means that all the hardware is already mapped to four HID (Human Interface Device) events. You just have to code your software to listen to these events. You can copy any code which listens to keyboard or mouse events.

If you want more than two buttons, you will need a fancy mouse with lots of buttons. If you need more than one rotary encoder, you can use an old mouse with a ball. The ball uses two rotary encoders, but these encoders are freewheeling (no click-stop like a scrollwheel). Freewheeling encoders are difficult to use in some situations where the user expects some clicky feel from the knob-turn.
Posts: 1415
Joined: Tue Jan 17, 2012 2:38 pm
by error404 » Tue Feb 14, 2012 9:19 pm
Teensy++ is another good option for building custom controls. You'll have to write some code, but people have probably done most of the work for you already as it's a popular application of the gadget.

It's probably possible to use the GPIO to do this as well, I think the SoC supports the necessary features, just not sure they're exposed in the driver. See: http://lxr.linux.no/#linux+v3......ncoder.txt
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm