How to setup a Rotary Switch with 1 Input

Опубликовано: 22 Март 2026
на канале: Scotty D
23,621
467

Struggling with a shortage of digital pins on your Arduino board? In this video, I've got you covered! Learn how to connect a rotary switch without depleting all your digital pins by employing just one analog pin.

🤔 Why Go Analog?
Traditional methods of connecting rotary switches demand multiple digital input pins, potentially exhausting your Arduino's available resources. Discover a smarter approach that conserves pins while efficiently managing your project's needs.

🔧 Applicable to Various Microcontrollers
This technique isn't exclusive to Arduino; it's compatible with a range of microcontrollers like Raspberry Pi, ESP32, and ESP8266, provided an analog pin is available.

📁 Get the Code
Access the code I used in this demonstration via GitHub: https://github.com/5cottyD/Projects/t...

🔗 Purchase Links from AliExpress here
ARDUINO UNO R3 CLONE: https://s.click.aliexpress.com/e/_DDV...
ARDUINO MICRO CLONE: https://s.click.aliexpress.com/e/_De4...
ROTARY SWITCH VARIOUS POLES: https://s.click.aliexpress.com/e/_DEE...

Purchase Links from Amazon here
ARDUINO UNO R3 CLONE: https://amzn.to/3T4CZgI
ARDUINO MICRO CLONE: https://amzn.to/3AFEHir
ARDUINO NANO CLONE: https://amzn.to/4g6DWyU
ROTARY SWITCH 12 POLE: https://amzn.to/3yYyVb2

⏱️⏱️VIDEO CHAPTERS⏱️⏱️
------------------------------------------------
0:00 Intro
0:07 Digital pin method Wiring diagram
1:30 Analog pin method Wiring diagram
3:06 Resistor value selection
4:17 Breadboard Example
7:18 Arduino analogRead input range from 0 to 1023
8:07 Rotary switch setup / wiring / soldering
9:45 Wiring diagram vs Rotary switch setup
10:00 Coding example for reading input only and Serial monitor output/results
11:30 Readings are never exact and fluctuate
12:04 Coding example for reading input and assigning pin number and Serial monitor output/results
14:04 Adjusting Switch number to analog value
14:33 Rotary switch end product
15:03 Project example with minimum pin usage

📺 Explore more electronics tutorials in this playlist:
   • Electronics & Projects  

🔔 Subscribe to the channel and hit the notification bell to stay updated with the latest Electronics videos and tutorials!
   / @scottydiy  

🔗 Check out Josephine's channel for her content:    / @josephine5766  

🔖 Tags: #arduino #arduinoproject #rotartyswitch