I want to blink more LEDs than available pinouts

Thanks PaulS. :slight_smile:

I'm sorry MKII1200, I don't expect you do do it for me but I need more than "You can handle all those LEDs with a few 595 chips". :frowning:

Also my whole source of hardware is eBay so if it isn't available there I can't get it. :frowning:

Thanks for all your replies.... :smiley:

http://www.ebay.co.uk/itm/2-PCS-74HC595-CMOS-IC-Bargain-Pack-74595-74LS595-CERAMIC-DIP-DIL-/320924233205?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item4ab8932df5

I'm sure there are other, maybe better, deals.

With a fairly simple setup I am blinking 32 LEDs:

Or you can use a MAX7219 to handle 64 LEDs if you wire them in a matrix:

Personally I would look at a few 74HC595 chips. After all, you are going to have to run wires one way or the other to 200 LEDs. May as well delegate the job. In any case trying to run them all from the main processor, you are likely to hit output pin limits. In other words, it probably won't be able to provide enough current to light 200 LEDs without transistors.

You can get LED strips fairly cheaply, and they run hundreds of LEDs from only 4 wires (power, ground, data, clock).

$17 per metre of LEDs (30 LEDs per metre).

From eBay?

http://www.ebay.com/itm/10M-3528-SMD-600LEDS-RGB-2X-5M-led-light-strip-44-Key-IR-Remote-Controller-/141282109267?pt=US_String_Lights_Fairy_Lights&hash=item20e511e753

Judging by the photo it uses the same concept (4 wires). You may have to play a bit to work out the connections but it shouldn't be that hard.

I believe the guy might need some hints on what is a 595.

They are serial to parallel converters: you send in an information 8 bits long using three wires (plus power lines) and they convert those 8 bits in 8 output lines.

So, without even trying to describe how you send those 8 bits to the 595 chip, if you send the binary sequence 01001000 it will turn on pins 3 and 6 and it will turn off all the remaining pins (out of a 0 to 7 numbering).

That means you have already added 5 pins to your pinout: using 3 pins you are able to drive 8. Those chips can be also daisy chained, meaning they provide an additional output pin which can be connected to the input pin of another one so that any data "overflowing" the chip is going to be "pushed" in the subsequent.

In other words, if you have two 595s daisy chained you can send them 16bits rather than 8: the first 8 bits will end up in the second chip (the one at the end of the chain) and the second 8 bits into the first one (that's why we call it overflowing).

With two daisy chained 595s you can drive 16 pins by using 3 pins on your arduino (not counting the Vcc and GND power lines).

There's a limit on how many 595s can be effectively daisy chained, but you can ramp this up a quite a lot before hitting those limits: I know guys driving 10 of those chips from an arduino with no troubles at all.

Now go read the 595 datasheet and get a better understanding if you think this might solve your problem, but do not forget 595s are not meant to provide a lot of current: the normal DIP package has a quite low limit on the amount of current you can provide from a chip, which is LOWER than the amount of current it can provide from each single pin if all the pins are turned on...

I wish someone had given me an explanation as the above one when I was trying to understand how these chips work.
It would have saved me a lot of time and troubles. :fearful:

MKII1200:
I wish someone had given me an explanation as the above one when I was trying to understand how these chips work.
It would have saved me a lot of time and troubles. :fearful:

Me too! :slight_smile:

That's why I tried to put it the simple way, even if I know it does contain some imprecision, but at least he should now have an understanding what we are pointing him at.

You might find this interesting:

I took a scrolling LED sign, worked out how it was wired up, and drove it from an Arduino.

It had 10 x 595 chips, plus 7 transistors. Between them they drive 504 LEDs. There is some multiplexing involved as clearly 10 x 595 chips can't directly drive 504 LEDs.

So, 9 of them drive the columns (9 x 8 = 72) multiplexed with 7 rows (7 * 72 = 504) giving 504 LEDs for a cost of only 10 chips.

You can buy 10 x 595 chips on eBay for around $1.50 so you can see the cost is not that high.

I'd go with 4 MAX7219s. I have this little breakout board for it, you can wire add LEDs with a pair of wires each and space the LEDs out however you'd like. Designed to be daisy chained together.
Using the MAX7219 is easy, write to a register directly with SPI.transfer, or with the LEDcontrol library.
http://www.crossroadsfencing.com/BobuinoRev17/

Thanks to everyone for all the informative responses :slight_smile:

Have to wait for my cables/wires/ties(?) to arrive from eBay. First lot are a week overdue so ordered 2 more lots from different sellers (hopefully one lot will arrive soon) :slight_smile:

Finding out lots about my Uno, like on-board 3.3V and analog pins can be used as digital :smiley:

Quick question - can I switch the on-board 3.3V with the pins? Or will this cause some sort of short circuit?

I played with the Blink example to make it blink four times then wait 2 seconds just to get my hands dirty :smiley:

The onboard 3.3V is just the output of a regulator. You can use it as a power source to other things, or add p-channel MOSFETs and switch the MOSFET on & off to let 3.3V current flow.

Sorry, I didn't make my question clear.

Can I use the digital (or analog) pins to switch the 3.3V output? I am worried that the digital pins go HIGH to 5V and how will that interact with the 3.3V? And can the pins switch the 3.3V?

Can I use the digital (or analog) pins to switch the 3.3V output?

No. The 3.3V pin is hot all the time.

I am worried that the digital pins go HIGH to 5V

They do. Nothing to worry about.

and how will that interact with the 3.3V?

Not well. You need level shifters between the 5V output pins on the Arduino and the 3.3V input pins of the other device.

And can the pins switch the 3.3V?

Which pins? What 3.3V?

Sorry again.... Absolute newbie here :slight_smile: I suspect the answer is no????

Can I switch the 3.3V output from the Uno board through the digital pins 0 to 13 (and analog pins 14 to 19)?

As I read it the HIGH on these pins (0 to 19) is 5V?

I haven't received the resistors I ordered so I wanted to see if I could avoid the requirement for these resistors by (trying) to connect the 3.3V through pins(?) 0 to 19 to my LEDs? HIGH in INPUT mode????

Maybe I should just wait for the 220 ohm resistors and use the 0 to 19 pins normally?

Sorry, am I making sense?

Unless you have a 3.3V powered microcontroller, the outputs will switch from 0-5V.
The Uno is 5V powered - it's outputs will go 0 to 5V.
LEDs always need a resistor. Once the forward voltage reaches their turn on level, they become very low resistance devices and will let all the current flow that is available. Then it's just a matter of time as to which fails first - the diode from overheating, or the IO pin from the output transistor overheating, and typically taking out other IO pins at the same time.

Next time order parts from US sources - digikey.com (Minnesota), mouser.com (Texas), dipmicro.com (Niagara Falls).
It's ridiculous to wait weeks & weeks for parts from China to save a few cents.

Can I switch the 3.3V output from the Uno board through the digital pins 0 to 13 (and analog pins 14 to 19)?

No!

As I read it the HIGH on these pins (0 to 19) is 5V?

You read correctly.

Maybe I should just wait for the 220 ohm resistors and use the 0 to 19 pins normally?

Yes, you should.

Sorry, CrossRoads....

On the Uno, under Power pins

IOREF - RESET - 3.3V - 5V - GND - Vin

This 3.3V output is the one I mean

See http://arduino.cc/en/uploads/Main/ArduinoUno_R3_Front.jpg

BTW I'm in Perth, Western Australia :smiley:

First of all pins marked as 3.3V and 5V are not digitally controlled: they are always on if the Arduino board is powered up. You have absolutely no control over them, they are not controlled by the MCU (micro controller unit) which is the IC (integrated circuit) you program. There are techniques allowing you to connect or disconnect those pins from other parts of your circuits, but they are clearly out of your reach at this moment.

When you use a 5V board (almost all the Arduino boards are) then by setting a digital pin to HIGH you are putting that pin at 5V (compared to GND pin as volts are never ABSOLUTE, they are ALWAYS relative).

This applies to analog pins used as digital pins as well.
When you use analogWrite you are NOT sending a part of 5V but 5V pulses (search for PWM on Google).
By using analogWrite(128) you send pulses of 5V followed by 0V each with the exact same duration (it is called 50% duty cycle).

In other words your entire board operates at 5V, but on Uno and some other boards you get a 3.3V pin as well: not because the board operates at 3.3V, but you can drive 3.3V modules throught it. You can use digitalRead and analogRead with modules operating at 3.3V because a 3.3V HIGH value is considered HIGH for a 5V pin as well.

When speaking about LEDs you cannot omit resistors, NEVER. LEDs are current hungry: once they turn on they will try to absorb all the current they can until either they burn out (best case) or the current source burns out (worst case because either you blown a pin on your Arduino board or you blown your board voltage regulator IC).

Whenever you read about people driving LEDs without a series resistor they are putting their LEDs and their boards at risk: I've read some saying you can use analogWrite, turn the LEDs on for very limited time and much more, but they are all wrong in their assumptions. If your board doesn't stop working you are definitely permanently damaging it, even if you do it for a few seconds.

As stated by CrossRoads, LEDs (and any other diode) can be treated as a short circuit once they start to conduct, which happens when the voltage reaches a pre determined level. Different LEDs have different voltage levels and it is called "forward voltage".

I found this web site very instructive when I started http://www.electronics-tutorials.ws/ and I suggest you follow at least the basic tutorials on resistors, capacitors and semi conductors as you are missing very basic information. I was at your exact same level just a few months ago, so don't get discouraged, but start studying some stuff.

louwin:
Can I switch the 3.3V output from the Uno board through the digital pins 0 to 13 (and analog pins 14 to 19)?

I suspect this is an X-Y question. Why do you want to?

rlogiacco, thank you for your very informative answer :smiley:

Are you saying that even on the 3.3V line I MUST have a resistor to an LED? If so what value?

I am under the impression a resistor (220ohm) is only needed when you connect 5V to an LED?

I have a USB power board (for the MB-102 breadboard) with 3.3V output and have driven 4 LEDs (granted only momentarily) on 3.3V without a resistors. And I have plugged in an LED on the 3.3V to GND (on my Uno) for a couple of seconds.

Are you saying this could damage the board and/or the LEDs? :frowning:

The 3.3V is/was why I was considering getting a Due instead of the Mega2560. I want to blink 200 LEDs (one or two MAX) so 200 resistors is a lot of wiring so I wanted to avoid them :wink: Are you saying I shouldn't wire LEDs on a 3.3V line without a resistor?

Are you saying I shouldn't wire LEDs on a 3.3V line without a resistor?

Yes. It isn't the voltage that matters. The resistor limits the amount of current that the LED can draw. The LED, when turned on, is basically a short circuit, and can draw a LOT of current - more than the Arduino can supply, unless the current is limited, somehow. That's what the resistor does.