New user here -- my name's Halle, I live in Berlin, and I just recently got acquainted with the Arduino and its many charms. This forum is great, cheers!
So, on my first Arduino project I wanted to use a couple of 7-segment LEDs and quickly ran out of pins, and while I was trying to figure out if I should get another chip to drive the LEDs I started to learn about multiplexing/charlieplexing, and decided to do it the hard way :), mostly because I thought it would get me past my lingering hangups about wiring diagrams and arrays. I primarily relied on this for the wiring:
and this for the code:
So, I wanted to post the current state of my wiring and sketch and see if I could get some feedback, and also share in case my progress so far would be useful to others. Everything works fine, but I think there could be some more polish. Thanks for any input!
Questions bugging me, in case anyone has a second to take a whack at them:
1) This still seems to work if I disconnect the +5v line. Why does it still work/why is the +5v line important? Does this come into play to a greater extent if I'm driving more than two 7-segments?
2) How is my resistor choice and placement? Could the resistors alternately go right after the data line?
3) I have some ghosting every once in a while (mostly when the number 4 is displaying on the second LED). Any suggestions about to minimize this?
4) This code works for my needs, since I will always have a two-digit number to display and I'm getting that number as two single digits. But, maybe it would be cooler to make it more universal, and I'd love to know if people see more efficient ways to structure things.
Here is the wiring:
Notes on wiring: according to various knowledgeable folks I've asked, this is unfortunately as charlieplexed as two 7-segment LEDs can be, due to the shared anode (or cathode). The pin savings for charlieplexing two 7-segment LEDs versus multiplexing is only a single pin. The upside is that you can drive up to eight 7-segment LEDs with the same number of pins! I have only tested this wiring and my code with two LEDs but expanding to more should be possible in accordance with the diagrams here:
BTW, I left the decimal point out of my wiring because I don't need it, but it would be added with another data pin which goes to the first decimal point, which goes to the second decimal point, which the same arrangement of resistors as on the other LEDs. Another place would also have to be added in all of the related arrays in the code as well.
Here is the sketch:
Code notes: I think that in order to add another led, you'd just have to make changes in the following places:
1) add a thirdNumber variable 2) add the next set of 7 pairs to ledPairs 3) add a thirdLed byte with the respective on/off patterns 4) get the thirdLed array into the entireNumber array 5) change the number 14 to 21 in all of the 'for' functions which get the array contents
but I haven't tested it. If anyone has more 7-segments lying around than I do and wants to give it a go, I'd be interested to hear if it works.
OK, thanks for any feedback, and if anyone is in my approximate neighborhood and wants to compare notes on where to get things here, or maybe go in on shared shipments from the US, drop me a line.