element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Need help optimizing an LED design controlled by rotary switch
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 14 replies
  • Answers 2 answers
  • Subscribers 394 subscribers
  • Views 890 views
  • Users 0 members are here
  • led
  • Charlieplexing
  • arduino
Related

Need help optimizing an LED design controlled by rotary switch

Former Member
Former Member over 10 years ago

Hello all I have a very specific project I am working on and while I have a working prototype I feel that there are things I can do to further optimize the design.

 

What it is


This is a simple feedback system for people to rate content they are watching live on a scale from -3-0-+3. The system consists of seven LEDs three red, followed by one blue and three green. These are controlled via a seven position rotary switch. I currently have this all plugged into gpio pins on an arduino mega and I would like to reduce the number of pins I am using. The reason I am using so many pins is I need to be able to light the leds sequentially i.e. three red, two red, one red, blue always on, one green, two green, three green. Meanwhile the Arduino program outputs the current selection over the serial port to a program that records this output.


What i want to do

 

Basically I want to reduce my pincount using Charlieplexing or some sort of led driver. I am currently using up 14 pins on the Arduino and I want to incorporate some other functions into this system. I am thinking charlieplexing is the answer but if there is a better solution I am open to suggestions!

 

Thanks in advance!

  • Sign in to reply
  • Cancel
Parents
  • dougw
    0 dougw over 10 years ago

    The rotary switch could be wired to turn on the LEDs directly - then all you need to do is sense switch position with the Arduino.

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • dougw
    0 dougw over 10 years ago

    The rotary switch could be wired to turn on the LEDs directly - then all you need to do is sense switch position with the Arduino.

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • Former Member
    0 Former Member over 10 years ago in reply to dougw

    Douglas, that is looking like what I need as far as the order of the LEDs. Stupid question, but would switch position open=pin HIGH and switch position closed=pin LOW on the arduino in this case? Or do I have it backward?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • dougw
    0 dougw over 10 years ago in reply to Former Member

    If you put a pullup resistor on each cathode, then the pin with the lowest voltage is the selected pin.

    This scheme would imply using 7 analog inputs. Note that some voltage dividers might be needed to keep the analog voltages in range of the Arduino.

    Another method would be to use a dual gang rotary switch or a switch with 2 wipers, then the second switch could be setup for sensing position independent of the LED circuit. (a switch with 16 or 18 pins but only 7 or 8 positions)

    There are several ways to connect the LEDs and the switch that would all work, depending on how many extra components you want to add, and what type of power supply you have available.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago in reply to dougw

    Understood thanks for the feedback. Overall im trying to minimize the number of components. I think I may have analog pins to spare, however using a dual wiper switch has advantages as well. Either way im going to need seven pins. Thanks for your help!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • dougw
    0 dougw over 10 years ago in reply to Former Member

    If you have an extra analog pin you could wire the second switch to output a voltage that indicates which position is selected - just put a series of 7 resistors between VCC and ground and wire the switch to tap into each junction. This whole system would only use one pin on the arduino.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago in reply to dougw

    Ill have to brush up on voltage sensing arduino, but I like that even better. Every pin counts since I am incorporating a proximity sensor, hid button and servos into this project as well. Eventually I want to design my own custom AVR board for this project with just the headers and connectors I need.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 10 years ago in reply to dougw

    So, I did a little research last night to discover that 7-position two-deck switches are a little hard to come by. Is the pull-up resistor method the only way to accomplish this with a single level switch? Thanks

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • dougw
    0 dougw over 10 years ago in reply to Former Member

    You could use the rotary switch with 7 resistors feeding a single analog input to indicate to the arduino which state is selected. Then you could de-multiplex 3 outputs from the arduino to implement the desired LED state.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube