Go Down

Topic: selfmade turn signal for bike (5x10 LED matrix) (Read 1 time) previous topic - next topic

koko_95

Hey guys,

so I want to build a turn signal for my bike. I've built a 5x10 LED matrix for that pupose that I want to connect to my Arduino UNO. I want to have arrows running from left to right or right to left when I press a switch.
And I really have no idea how to connect that to my Arduino.

I know that I can use the analogue pins as digital output pins so I was really happy, to have just enough output pins, but now I need two more for the chwitch, right?
I'd be really happy about some help, since this is my first Arduino project ever.

Thanks!

koko_95

I have the anodes in columns and the cathodes in rows if that is of any importance.
I know, that this might seem like a silly question to some but just consider me as a total newbie, I don't know any of this stuff... :smiley-confuse:

PaulRB

Hi, before we can help you, you need to give more information. Tell us about the leds you have used. RGB? Single color? Forward voltage, max current? Do you have a link to some info about them from the seller? How did you test them? Can you post a picture of the front & back of the matrix?

INTP

What's the problem? 5x10 gives you 15 pins, Uno has 14 digital pins and 5 analog. How are you out of pins?

CrossRoads

Uno has 20 digital, of which 6 are also analog input. And there are 2 additional analog-input only pins (no digital function) broken out on many boards that use the SMD '328Ps.

Sounds like you are using just 17 IO, and can leave D0/D1 free for downloading code and debugging via serial monitor.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

CrossRoads

So your question is really more about multiplexing.
You can turn on/off 1 LED at a time, with a loop within a loop. Have your data representing the LED states in an array, read the array and turn on/off each LED as needed. Have the pins used in arrays also to make looping thru them easy:
Code: [Select]

for (outerLoop = 0; outerLoop <5;  outerLoop = outerLoop +1){
  for (innerLoop = 0; innerLoop <10;  innerLoop = innerLoop +1){
      if (dataArray[outerLoop] [innerLoop] == 1){ // check syntax on that
     digitalWrite (anodePin[outerLoop], HIGH);
     digitalWrite (cathodePin[innerLoop), LOW);
     }
    else {
    digitalWrite (anodePin[outerLoop], LOW);
     digitalWrite (cathodePin[innerLoop), HIGH);
    }
  } // end innerLoop
} // end outLoop

 Then flesh it out some more, adding blink without delay timing so  the LEDs stay on for some minimum time before going to the next one, decide how many times the pattern should display, read a button to start the pattern being displayed, etc.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

INTP

With a 5x10 I'd go up to 5 leds on at a time and keep the scan process along one axis for a smoother display. Borderline flicker realm is exacerbated on the road.

Code gets a bit heavy on the learning curve but if you are at all modestly literate, there are a ton of resources to learn from.
You can basically draw whatever shapes you want, like arrows, in an array of 0's and 1's, and use a scroll function to get the moving arrow you want.

If you're interested in just having something that works, you can keep it simple by ditching arrow shapes and just using vertical lines that scan left to right and r-l.

If left signal button pushed, turn on right most column, turn it off, turn on next, off, etc. Easy for loop there. If you have column anodes and row cathodes, for example, cathodes can just say written LOW and anode columns would go HIGH to light the respective columns.

INTP

I actually just soldered together an 8x8 matrix, and gave it a test as 5x8.

Video

koko_95

I actually just soldered together an 8x8 matrix, and gave it a test as 5x8.

Video
Haha, this is like so amazing! I'm sitting here and trying to figure out how I'm going to make this work and you just do it! But I guess I'll get there in a while, I'll post pictures asap, and look up which type of LEDs they are.
Still, could you show me the back of your matrix? Did you use transistors? i thought I don't need them.
Thanks to all of you!

PaulRB

#9
Aug 16, 2016, 01:54 pm Last Edit: Aug 16, 2016, 01:55 pm by PaulRB
Did you use transistors? i thought I don't need them.
You can make led matrices work without transistors or other chips, but to avoid damaging the Arduino, you have to use high-value series resistors (e.g. 1K) to keep the current low. Combined with the multiplexing (1:5 or 1:10), this makes the display quite dim indeed. You need it to be visible outdoors in daylight, so transistors or some other driver chips will probably be vital.

koko_95

You can make led matrices work without transistors or other chips, but to avoid damaging the Arduino, you have to use high-value series resistors (e.g. 1K) to keep the current low. Combined with the multiplexing (1:5 or 1:10), this makes the display quite dim indeed. You need it to be visible outdoors in daylight, so transistors or some other driver chips will probably be vital.
Okay and how do I know which transistors I have to use?
this is what it said on the package of my LEDs: 2,25V 20mA(11mcd) <-don't know what that is

Also do I need transistors on both columns and rows? Because I found that on the internet but I don't really get why. Thank you guys for the help!

INTP

While working with directly wired matrices, I just used a resistor on every column (none on rows, or vice versa).
The rest of the work is just coding.

With a 5x10, you need at most a 500ish ohm resistor when at most 5 leds will be on at the same time. And at multiplexing speeds, you're safe to go higher current, even moreso if you know your end design. For example, the arrow in my vid has at most only 3 leds in a column on at a time and very briefly before it's off to another column (and therefore pin).

PaulRB

11mcd sounds like a mistake. 11,000mcd maybe. mcd stands for milli-candellas, which is a unit of luminous intensity. In other words, how intense is the light in the direction in which it is brightest. That's different from total light output, which is measured in Lumens. Two leds might output the same total amount of light (lumens) but one might have a much higher intensity than the other because it puts out its light in a much narrower beam, whereas the other has a much wider viewing angle.

For your turn lights, I think brightness is important. To get the most brightness, you need to supply the maximum current you can to the leds, and minimise the multiplexing ratio.

Your leds have a max continuous current of 20mA, but as INTP says, you can often exceed that limit if you are multiplexing, because the current will not be continuous. Question is, by how much can you exceed it. Even top quality leds from big name manufacturers only give very brief information on this in their data sheets. For example, the max pulsed current might be 100mA, but the pulses have to be no longer than 0.1ms with a 10ms delay between pulses.

But for less expensive, brand-X leds, no such information is available and you exceed the max current at your own risk.

With your 5x10 matrix, you can multiplex either by row (giving a 1 in 5 multiplex ratio) or by column (givng a 1 in 10 ratio). If you can't safely exceed 20mA, it would be better/brighter to go with multiplexing by row.

This would mean up to 10 leds lit at once, a total of 10 x 20mA = 200mA. This is the limit of what the Uno's chip can source or sink. Even so, you have to be careful to spread the current between ports so that no port exceeds 100mA.

Switching the rows will require transistors or a driver chip, because the Uno's pins cannot deal with 200mA. As your rows are common cathodes, I would recommend 5 x bc337 transistors as low-side switches.

Your led series resistors would be on the columns, so 10 of them. Ideally, value should be (5.00 - 2.25) / 0.020 = 137R, so go for next highest available value 150R.

You also need 5 resistors on the bases of the transistors. Assuming gain of 50, they should be 5 / (0.2 / 50) = 1.25K, so 1K should be OK.

koko_95

#13
Aug 19, 2016, 11:36 am Last Edit: Aug 19, 2016, 11:44 am by koko_95
With your 5x10 matrix, you can multiplex either by row (giving a 1 in 5 multiplex ratio) or by column (givng a 1 in 10 ratio). If you can't safely exceed 20mA, it would be better/brighter to go with multiplexing by row.

This would mean up to 10 leds lit at once, a total of 10 x 20mA = 200mA. This is the limit of what the Uno's chip can source or sink. Even so, you have to be careful to spread the current between ports so that no port exceeds 100mA.

Switching the rows will require transistors or a driver chip, because the Uno's pins cannot deal with 200mA. As your rows are common cathodes, I would recommend 5 x bc337 transistors as low-side switches.

Your led series resistors would be on the columns, so 10 of them. Ideally, value should be (5.00 - 2.25) / 0.020 = 137R, so go for next highest available value 150R.

You also need 5 resistors on the bases of the transistors. Assuming gain of 50, they should be 5 / (0.2 / 50) = 1.25K, so 1K should be OK.
This helped me so much, thank you!
i have just otwo more questions:
1. do I connect "drain" from the transistor to power and source to my cathodes or the other way around?
2. since english is not my first language: multiplex by row means one row 10 leds  at a time light up?

And on emore time (sorry!): every schematic I find shows transistors on both columns and rows? But you say I only need them on rows?

PaulRB

#14
Aug 19, 2016, 07:20 pm Last Edit: Aug 19, 2016, 07:25 pm by PaulRB
1. What type of transistor do you plan to use? The bc337 I recommended do not have a drain. They are BJT transistors and have a collector, emitter and base. FET transistors have source, drain and gate.

2. Yes, assuming your matrix has 5 rows and 10 columns.

3. You would need transistors on columns if the total current exceeded what the controlling chip could supply. For 10 leds @ 20mA, the ATMega328 can just about supply enough to light all 10 columns. If you will be displaying an animated pattern, perhaps only half the columns will be lit at any instant, so you will not be too close to the limit.

Go Up