0
\$\begingroup\$

I'm working on a project that is used to monitor how many parts I have left in my cupboard of bits.

There are 5 separate parts whose level I want to monitor, each part will have 3 LEDs to display the stock level. I'm planning to use bi colour LEDs (L-59EGW-CA) in the following configuration: LED Configuration

I will be using 15 LEDs in total (3 per part x 5 parts). I'm planning to drive the circuit from an ATMEGA328P (Arduino UNO) and will have an Up/Down increment pushbutton for each part (5 up, 5 down in total)

I started to design a circuit for the system and came up with the following (Please bear in mind this is just a representation of the circuit, I'm aware there is not enough outputs etc.)

enter image description here

Datasheets:

  1. ULN2803A
  2. CD74HC4514

The ATMEGA328P goes through the decoder to the transistor array which switches the LED on. Now this would be good, if I only had 1 part. I've realised that because I have 5 parts I can't have multiple channels on the decoder on simultaneously. For example, in my diagram I want both the LEDs to be on, however they're for different parts so I can't just common the cathodes together.

After a long introduction here's my actual question:

1. Is it possible to have multiple outputs of the decoder on simultaneously?

I was thinking that if in the arduino code I kept switching between the decoder channels (and allowing for prop delay) then I could light the LEDs however they'd be dimmer due to a PWM type effect

2. After my input pushbuttons I have 10 digital pins left over for the 5 different parts. Is there another way to do the LED sequence using only 2 pins?

I've had a go using just 2 pins, I had to change to using a common cathode bi colour LED as opposed to a common anode and it uses 3 chips and a diode. It also means that I can only have 1 flashing red LED rather than 3.

enter image description here

Would this work, and is there a simpler way of doing this?

If you think I'm being a complete tool and that there's a better way then let me know

Sorry for the massive wall of text guys.

I am not using just 3 LEDs I've stated in the question that I'm using 15 and that the schematics are a representation as to not clog it all up

\$\endgroup\$
  • \$\begingroup\$ Shift registers are the other way of doing this, can be used with just 3 pins. \$\endgroup\$ – pjc50 Jul 22 '16 at 9:53
  • \$\begingroup\$ You have effectively 6 LEDs in 3 packages. Why not drive them directly from the atmega (6 separate I/O lines) to give your combinations. 3 Green only, 2 red/green (amber) only, 1 Red only and 3 red only flash. (no logic decoder required.) Make sure you add an appropriate series resistor. \$\endgroup\$ – JIm Dearden Jul 22 '16 at 9:53
  • \$\begingroup\$ @JImDearden I simplified the design as to not make it too confusing. I have is 3 bi colour LEDs but I have this repeated 5 times. so all in all I have 30 LEDs (15 bi-colour LEDs) \$\endgroup\$ – Doodle Jul 22 '16 at 9:59
  • \$\begingroup\$ @pjc50 For all 30 LEDs would I have each LED to the output of a shift register? Then I'm assuming I can connect 5 of them directly to the MCU (As I have 10 pins spare and would need 7? 5 data and a shared SRCLK and RCLK?) \$\endgroup\$ – Doodle Jul 22 '16 at 10:07
  • \$\begingroup\$ @Hayman you can just daisy-chain them, and you get 8 LEDs per shift register. So that would give you 32 LEDs from 3 pins and a chain of 4 shift registers. lucidtronix.com/tutorials/40 \$\endgroup\$ – pjc50 Jul 22 '16 at 11:15
1
\$\begingroup\$

One solution is to use shift registers. That tutorial details the 74HC595, which is the usual choice. You can daisy-chain them by connecting the clock, latch, and reset pins of all of them together, then the Q7 of one to the input of the next.

You don't have to use the reset pins. If you don't, wire them to the positive supply. However, setting and then clearing reset before sending bits ensures the system is in a consistent state.

Then just go through a loop of setting the output pin to the next value and turning the clock pin high/low on each cycle. Once completed, send a pulse on the latch pin to actually commit the change to the outputs.

Don't forget, one decoupling capacitor per 74HC595, close to its power/ground pins.

Disadvantages: any fault stops all the downstream LEDs from working. Long strings take longer to program. Doing it at high speed may cause EMI and be unreliable. Fortunately the 595 has no minimum speed, so you can do it at kilohertz speeds which makes it more reliable and easier to follow with a scope.

Long strings (tens of devices) also may require repeaters on the clock/latch/reset signals, and require adequate power arrangements to avoid brownouts at the far end.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.