Page 1 of 1

Rotary switch

Posted: Wed Jul 29, 2026 3:31 pm
by siliconchip
Hi all
Im looking for examples on how to use the rotary switch but cant find any im after a 5 pin ive tried using the rotary switch 0-15 but cant work out how to use it as when configured as a 5 pin there are only 3 connections pin 1 pin 2 and pin 4 ?? thanks inadvance

Bob

Re: Rotary switch

Posted: Wed Jul 29, 2026 4:03 pm
by chipfryer27
Hi

I haven't used that component and I see that there isn't an example yet.

However by clicking the number of positions in Properties it appears that it is giving a binary output dependent on the number of positions. So if you had only one position it uses VDD and one pin.

Two pins gives a value of up to three (01/10 / 11) positions etc
Four up to 15 positions

I'm sure you get the idea.

Regards

Re: Rotary switch

Posted: Wed Jul 29, 2026 4:07 pm
by siliconchip
Hi chipfryer
I agree with that but im unsure where to put the binary code in relation to the switch

Bob

Re: Rotary switch

Posted: Wed Jul 29, 2026 5:14 pm
by chipfryer27
Hi

I see what you mean. A bit confusing.

I'll have a closer look later and get back to you.

Regards

Re: Rotary switch

Posted: Wed Jul 29, 2026 5:23 pm
by Bijumon
Hi,

It looks like this component is made for a BCD (Binary-Coded Decimal) thumbwheel switch (as shown in the attached picture), rather than a standard rotary switch with a common pin and individual position connections.
Unlike a standard selector switch, this unit outputs a 4-bit binary code (pins 1, 2, 4, and 8) corresponding to the selected digit (0–15).

Re: Rotary switch

Posted: Wed Jul 29, 2026 5:28 pm
by Steve-Matrix
Can someone post a specific part number or datasheet for what you are wanting (especially if it is commonly used and/or standard), and we'll have a look at creating one.

Re: Rotary switch

Posted: Wed Jul 29, 2026 5:39 pm
by chipfryer27
Hi

As far as the component goes, attached is an example that hopefully explains it's operation. You mentioned five positions so that is what is being used,

In the chart I have a 3 x LED array connected to A0 - A2 and this will provide the binary output. The switch is connected to B0 - B2 (with VDD being a common).

There are two component macros, set position and get position.

Set position sets the value to whatever you want and in the example it sets it to "3".

In the loop it simply reads the current value of the switch (binary value) and displays on the LED array.

If you step through and in Simulation Debugger look at the variable Switch, you will see it reflecting the position.

Hope this helps.