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
Project Videos
  • Challenges & Projects
  • element14 presents
  • Project Videos
  • More
  • Cancel
Project Videos
Documents Charlieplexing Buttons and LEDs at the Same Time - How Hard Can It Be? -- Episode 604
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Project Videos to participate - click to join for free!
Related
Recommended
Engagement
  • Author Author: tariq.ahmad
  • Date Created: 10 May 2023 5:43 PM Date Created
  • Last Updated Last Updated: 26 May 2023 7:24 AM
  • Views 30041 views
  • Likes 9 likes
  • Comments 15 comments

Charlieplexing Buttons and LEDs at the Same Time - How Hard Can It Be? -- Episode 604

So many buttons so little IO. When you want to drive a large number of LEDs or read buttons the obvious choice is multiplexing them. But there is a method called charlieplexing that lets you use even more LEDs and buttons with even less IO pins. Clem wants to interface a large amount of buttons and LEDs with a microcontroller but has a limited number of pins.   He's also trying to save money on parts. Could you just replace expensive signal diodes with cheap LEDs? Could you use the same pins to read buttons and drive LEDs in the same matrix? Could you also achieve true n-key rollover without having a diode on every single button? How hard can it be?

Watch the Video:

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Bonus Content:

  • Login to Download the Code!

Bill of Material:

Product Name Manufacturer Quantity Buy Kit
LED, Super Red, Through Hole, T-1 3/4 (5mm), 12 mA, 5 V, 640 nm Multicomp 9 Buy Now
Arduino Mega 2560, ATmega2560, 54 I/O, 256KB Flash, 8KB SRAM, 4KB EEPROM Arduino 1 Buy Now
Jumper Wire Kit, Multicolour, 2 mm - 125 mm, 22 AWG, 140 Piece Multicomp 1 Buy Now
Breadboard, Mounted, 1580 Pin, 10mm, x 135mm Multicomp 1 Buy Now
 

element14 presents

element14 presents  |  About Clem  |  Project Videos

  • buttons
  • keyboard
  • multiplexing
  • leds
  • Charlieplexing
  • arduino
  • friday_release
  • arduino mega
  • e14p_CMM
  • Share
  • History
  • More
  • Cancel
Actions
  • Share
  • More
  • Cancel
  • Sign in to reply
  • phoenixcomm
    phoenixcomm over 1 year ago

     mayermakes Mike, this is a very sore subject with me.  I have considered using Charileplexing my Navigation Display Unit to refresh your minds this beast has 13 seven-segment displays and 4 sixteen-segment displays. I was first introduced to it when I was looking for an IC to drive this mess. I came up with a MAX6955 the problem was two-fold

    1. my displays are Pinlite and they are incandescent
    2. Not only it is plain in the rear to wire but try and debug it. I double dare you.

    came up with my own solution which which needed 3 seven-segment decoders driven from an Arduino Mega I also used an MCP23016 to drive the four 16-segment displays. The word drive is a misnomer it should have been select. This requires 7 selects (7-seg) and 16 selects (16-seg) which is (16x4) + (7x13) ::= 64+ 105 = 169 each driven by a transistor. 

    Then you need 17 more selects that drive one transistor per select.  so that 17 + 169  transistors moral of the story? Why in gods name do we have to make our crap harder than it has to be? Yes, it works in production, when pennies count. Never in experimental electronics. It should have been buried a long time ago. Some folks like Mike like to flagellate themselves. Also, don't ever obfuscate something.  As Mr T. said "pitty the fool!" the problem is you end up being the fool when you have to figure out why the creation aka Frankenstein does not work.  

    I have probably said too much. ~~ Cris H. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mayermakes
    mayermakes over 2 years ago in reply to phoenixcomm

    yeah, its obvious why its mostly done with leds and buttons, and not high current devices.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mayermakes
    mayermakes over 2 years ago in reply to shabaz

    loading off code complecity to dedicated ICs is clearly adavantageous for sophisticated designs. the thing i inparticular like a botu a combined chalieplexed matrix of buttons and leds is the ability t ochange its purpose in software.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mayermakes
    mayermakes over 2 years ago in reply to DAB

    still a significant skill to learn, with the advent iof a new genration of low cost but I/O limited mcus it is still important.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • phoenixcomm
    phoenixcomm over 2 years ago in reply to mayermakes

    easiest way to get more pins is the MCP23016  you get two ports of 8 or use them all 16 pins max I sink or source = 25ma  remember you only need 1.5 volts to drive the LED. but sinking is better. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • phoenixcomm
    phoenixcomm over 2 years ago

    I ran into "Charlieplexing", about 20 years ago when I was going to use a MAX6954 to drive four 16-segment incandescent and another thirteen 7-segment incandescent displays. The displays are used on my NAV panel, Since they are incandescent and not LED my search continues. My search continued for some time, and basically, it takes an entire Arduino Mega to do the job, :(   plus a boatload of BJTs (Bipolar Junction Transistor) as it turns out you need one BJT on every segment, and one more for the common rail. So It's a lot of parts. this includes two BCD to 7 segment decoders as the fan-out is too much, could use three but then there are the enables to consider.

    The 16 segments are going to be driven directly (via BJTs) to one group of 4 devices. So I need 145 segment pins plus 17 more for the column drive. I you don't want to see refresh then your rate is < 0.2 seconds, and if you do the math .20 / 17 you end up with 0,011764706 if you round down it's 0.012 sec/per column. ouch. 

    In my opinion, "Charlieplexing" is nice but I really don't want to use this technic, as you don't want to try and fix a dead segment. :( It's a headache and you will need more than a few pints to get through it. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • shabaz
    shabaz over 2 years ago

    From what little I've seen, Charlieplexing can work well. Plus, it's ultra-low cost which can be a huge advantage.

    As another approach, sometimes dot-matrix boards use a single serial-to-parallel logic IC, like (say) 74HC164 for (say) a row, and then does a round-robin scan across the column with a johnson counter type IC like 74HC4017.

    Another classic way is the MAX7219, which (contrary to the typical use for it) doesn't need to be used with 7-segment displays, it can control arbitrary LEDs in any matrix/array up to 8x8 (and they can be chained up for multiples of 64). Works brilliantly, I used a couple of them once for driving 120 LEDs for a clock dial display. The benefit is that the code doesn't need to do any scanning, but the disadvantage is the cost (MAX7219 is really expensive nowadays, but there are ultra-cheap clones of it). There are lots of modern LED driver replacements (some with bult-in keyboard scanning), but the MAX7219 probably has a ton of example code since it is so mature.

    For buttons, a cheap approach that eliminates scanning code effort, is to use an I2C or SPI I/O expander IC, because most of them have an interrupt output. The code just needs to read the I/O expander whenever the interrupt occurs. But as mentioned, all of these approaches will cost more in hardware (but simplify the software).

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 2 years ago

    Nice build Clem.

    Back in the 1970's and 1980's we always multiplexed buttons to keep the I/O count down.

    We had very few I/O pins in those days, so we had to maximize what we could do with them.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dougw
    dougw over 2 years ago in reply to mayermakes

    I only push one at a time.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mayermakes
    mayermakes over 2 years ago in reply to dougw

    so are you using a diode on every single button or do you not care about n-key rollover in your button matrices?
    I have used latched decoders before, but it required a library that I viewed as not fast enough to do what  I wanted.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • 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