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.


Build your own Wifi radio

Step 7Using a rotary encoder

Using a rotary encoder
All input in this project is done by a rotary encoder. It is basically the same as your mousewheel including the push-function. However, where your mousewheel is most likely an optical encoder, I used a mechanical encoder for my project.

A rotary encoder on A and B channel (both a pin) with one common pin that can be either connected to GND or Vcc. As we use it with interrupts, we'll connect it to GND. The A and B channel open and close in a fixed patern and by reading this pattern, we know in what way the encoder is turning. By adding one channel to and interrupt, we are able to trigger the read subroutine automatically when the encoder is turned.

In bascom, that will give us:

A Alias Pind.3
B Alias Pind.4

Config A = Input
Config B = Input

Config Int0 = Falling

Dim Counter As Integer

Set B

On Int0 Getencoder

Counter = 0

Enable Interrupts
Enable Int0

Do

Your code here

Loop

Getencoder:
Waitms 1
If A = 0 Then
If B = 0 Then Incr Counter Else Decr Counter
End If
Return

End



The pushbutton on the rotary encoder works just like a normal button, so nothing much to explain there.

« 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!
91
Followers
25
Author:janw
My hobbies are mainly music and electronics but I like to read and learn about a lot more than that.