3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

How to Read Binary/Hex Thumbwheel Switch with an AVR Microcontroller

How to Read Binary/Hex Thumbwheel Switch with an AVR Microcontroller
This instructable will show you how to read the number on a binary pushwheel or thumbwheel switch using LED's or an AVR microcontroller (I'm using an ATmega328p but this can be adapted for any AVR or probably another microcontroller of your choice). Multiple thumbwheel switches can be strung together to make an electronic combination lock, protecting your valuable...um....cookies!

Thumbwheel switches have detent buttons (technically called a "pushwheel") or a wheel that you can push to change a number up or down by one. Inside they have switch logic that encodes the number on the dial as, typically, octal, hex, BCD (Binary Coded Decimal) . This encoding is then sourced to or sank from the external pads where it can be read and displayed (as with LED's), decoded with IC's (e.g. 4029,74HC93,and 74HC590), or hooked into input pins of a microcontroller and further processed.

My favorite local electronics shop had a bin full of ones that looked like old SCSI device ID switches so I grabbed a few to see how they worked. The numbers go from 0 to 15 so I think this would traditionally be called a hex switch, but I'll be referring to them as binary because of the output we're working with. Don't confuse binary with BCD; they are not the same thing. Ok, let's go!
 
Remove these adsRemove these ads by Signing Up
 

Step 1Parts List

Parts List
For this instructable you I am using the following parts:

You Probably Need These

  • A binary pushwheel or thumbwheel switch. These can be had at the major electronics outlets online, or if you're in Colorado, check out J.B. Saunders in Boulder. They have them on the cheap!
  • A solderless breadboard
  • A soldering iron, solder, hookup wire (I used 24 gauge stranded because it's very bendable)
  • An AVR microcontroller
    • I'm using an ATmega328p sitting in a Bare Bones Board from Modern Device
    • I'm using the USB BUB to program the AVR

Optional

  • Four LED's (for illustration of the encoding)
  • Four resisters (for the LED's. I used 200 Ohm that I had already on my bench (I'm lazy2))
Modern Device]
  • Four diodes if you're paranoid about running reverse polarity into the pins of your MCU

Something to write or compile your firmware

Windows

  • WinAVR for Windows AVR development

FreeBSD / Linux (other *NIX variant)

   pkg_add -r avr-gcc  -or-  cd /usr/ports/devel/avr-gcc/ && make install clean   pkg_add -r avr-libc   pkg_add -r avr-gdb

Mac

There are other utilities, like Eclipse, that you may also like to use but this should be a good start.

Now that you know what you need, we'll put it together, but in order to do that you need to know how the binary switch works.....so let's move on to the next step!

« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
63
Followers
22
Author:nevdull(The Bold Scientist)
Gian is the VP Research & Development at Open Design Strategies and holds a BA in Molecular/Cellular Biology and an MS in Computer Science. He has a collection of 8-bit microcontrollers and a room fu...
more »