In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Peter Van der Zee wrote: Hi Chris; The only sane way to do this is to multiplex the leds. It only takes 12 I/O pins to drive 32 LEDs, and the only other components you need are 8 resistors. So the total cost is about as low as you can get, and it works great. Forget all that other (in my opinion not well founded) advice about extra shift registers and transistors .... they simply are not needed, and just drive the software as well as hardware complexity up unnecessarily. Arrange 4 banks of 8 LEDs each, with all 8 cathodes of one bank connected together, and each of these goes to one of four port "sinking" bit. Connect one LED anode of each bank together and through a 560 (or so) ohm resistor to one of 8 port "sourcing" bits. This results is 8 port bits selecting which LEDs (up to 8 simultaneous) of a bank will be energized, and 4 port bits, one at a time, select which bank will be active at any moment. Then the software quickly (perhaps around 1 millisecond) steps around, activating each bank in round-robin sequence, and you get the APPEARANCE of up to all 32 LEDs being on simultaneously due to the eye's luminescent persistence, even though only up to 8 are ON at any 1 millisecond instance. The maximum current in this scheme would be 8 times (5 volts supply minus 1.5 volt LED forward drop) divided by the series resistor. This becomes 8*(5-1.5) / 560 = 50 mA .... easy for a bank sinking bit to handle. For greater brightness, the resistors could probably be safely reduced to 470, or possibly 390 ohms. The multiplexing software is quite simple and can be tackled in numerous ways. I like to employ a simple RTOS (Real Time Operating System, or actually more of a co-operative scheduler) for such tasks as it isolates other activities such as time-of-day counting, push button monitoring and alarming all as separate "simultaneous" tasks with virtually no interaction between them. If you are interested, I will post the code for this RTOS and multiplexing code (although I use assembly almost exclusively), and you can add your other clock or time keeping functions whatever they may be. Perhaps I could also add a schematic drawing, but first I'd have to figure out how to make one that can be posted here. Any advice on that ??? Anyhow, that's my advice to your post.... let me know. Cheers, Peter (pjv) ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=162118#m162172 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)