Go Down

Topic: Need help powering a 7.5V 7 Segment LED with Arduino Mega (Read 5287 times) previous topic - next topic

officialxian

Great! Thank you so much. I used that tut, and got the digitalRead(); to change with the button press. Everything is slowly coming together! Thanks to everyone who helped!! :D

officialxian

Okay, now what am I doing wrong?! I followed this tutorial to set up my common anode 7-segment display, and it's still not working. I modified the code and pins a little bit but other than that I followed it to the T. Here's my code...

Code: [Select]

/* 7 Segment LED Controller
* Board: Arduino Mega 2560
* LED: SM4123-1 ( http://www.yxztdz.com/EnProductShow.asp?ID=206 )
* By Official.xian
* 2014.05.31
*/

int anode1 = 22;  // Anode
int anode2 = 23;  // Anode
int led1 = 23;  // E - Bottom Left
int led2 = 24;  // D - Bottom Middle
int led3 = 25;  // C - Bottom Right
int led4 = 27;  // B - Top Right
int led5 = 28;  // A - Top Middle
int led6 = 29;  // DP - Dot Point
int led7 = 30;  // F - Top Left
int led8 = 31;  // G - Middle Middle

void setup(){
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led5, OUTPUT);
  pinMode(led6, OUTPUT);
  pinMode(led7, OUTPUT);
  pinMode(led8, OUTPUT);
 
  digitalWrite(anode1, HIGH);
  digitalWrite(anode2, HIGH);

  digitalWrite(led1, HIGH);
  digitalWrite(led2, HIGH);
  digitalWrite(led3, HIGH);
  digitalWrite(led4, HIGH);

  digitalWrite(led5, HIGH);
  digitalWrite(led6, LOW);  // This is the DP, I have this as the only LED turned on because I know that Arduino will power it (found out by accident a couple days ago)
  digitalWrite(led7, HIGH);
  digitalWrite(led8, HIGH);
}

void loop(){}


And here's how I have everything set up...
Here's a link to the pix...

Can someone help, please! I don't get this. I'd be fine if I had a common cathode LED, I've already made that work (smaller scale, from the Radioshack Electronics Learning Lab).

-xian

wes000000

you didn't call pinMode on anode1 and anode2. You have to set them as outputs.

In addition I believe when you set the ledx pins LOW they will turn on. So try setting pinMode for anodes and setting led1-8 to LOW.

Your picture link was broken, can you put up another? And why two anodes?
"I have not failed. I've just found 10,000 ways that won't work." - Thomas A. Edison

CrossRoads

What's the common anode connected to? I don't see a 7.5V connection there.
Nor a buffer chip like ULN2803.
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.

wes000000

I was assuming he is just using 5V as an anode for now in an effort to get at least one segment displaying something .I would expect it to still work just not be as bright.

And I think similarly in an effort to get something working he has just directly connected the micro controller pins to the 7 segment display.
"I have not failed. I've just found 10,000 ways that won't work." - Thomas A. Edison

officialxian


you didn't call pinMode on anode1 and anode2. You have to set them as outputs.

In addition I believe when you set the ledx pins LOW they will turn on. So try setting pinMode for anodes and setting led1-8 to LOW.

Your picture link was broken, can you put up another? And why two anodes?


http://xianmc.url.ph

Alright added
Code: [Select]
pinMode(anode1, OUTPUT);
pinMode(anode2, OUTPUT);
to the code, uploaded, and still nothing. Also, 2 anodes because there are two common anode pins on the LED.
Also switched all the ledx pins to LOW. Still nothing. I had just the DP on LOW because I knew the Arduino could power the DP.

Pic #1 (TinyPic)
Pic #2 (TinyPic)

-xian

wes000000

#21
Jun 01, 2014, 04:43 am Last Edit: Jun 01, 2014, 04:48 am by wes000000 Reason: 1
what size resistors are you using. it looks like 10kOhm from the pic and that's way too much I would think.

If you are indeed using 5V as your anode and 10k resistors that is only letting half a milliamp through each LED...

This link still wont open for me:
http://xianmc.url.ph

Also you probably shouldn't be using I/O pins as you anode supply. I would say plug the anode pins both into the 5V rail on the arduino itself. Because I know the Uno has a current output limit per pin of 40mA. Not sure if that # is higher for a mega, but either way it would be a safer bet to control with the 5V rail
"I have not failed. I've just found 10,000 ways that won't work." - Thomas A. Edison

wes000000

Just noticed your anode2 and led1 have same pin #, that could be a problem. Since you are setting it HIGH, then immediately low again. Get rid of duplicate pin numbers!

Attention to detail is the name of the game!
"I have not failed. I've just found 10,000 ways that won't work." - Thomas A. Edison

officialxian

Sorry, was def not paying a whole lot of attention last night. Rewrote the code and proofread it, tried all LED pins on LOW, no luck , tried just DP on LOW, still no luck. Also switched the anodes to the 5v rail on the Mega. This is so much harder than it needs to be. I'm debating just buying a bunch of common cathode LEDs. I have more experience with them and they're much easier, IMO.

Okay, just a shot in the dark here, but maybe (just to try to get this stuff working) I could do something with my ELL? I was thinking having the ELL power the LEDs, and use the arduino as just a switch? I know that the ELL can power the LEDs, that's how I tested them before, so what if the power came from the ELL, and the Arduino just controlled the power? Do you guys get what I'm saying, or does it even make sense? If so, is it plausible, before I spend a bunch of time trying it? Thanx everyone!!

-xian

officialxian

UPDATE

So I just plugged the 7 segment LED I've been using to test this into my ELL, turns out that one of the segments and the DP either don't work. Just tried a couple other LEDs, and finally found one that works 100%. Now I guess it's time to try this again. >.< Ugh this whole project has been a huge pain. But for some weird reason, I like it. xD

officialxian

PARTIAL SUCCESS

Alright!! Hooked up the new LED to the Mega and got the DP to work!! I just looked closer, and I think that they're *all* on! They're extremely dim, though. :) Now, I have the button working, and I think the LEDs working (dimly) now I need to boost the power, right? I would do that...how? Transister, shift register, etc. has gotten me really confused.

wes000000

#26
Jun 02, 2014, 01:33 am Last Edit: Jun 02, 2014, 01:34 am by wes000000 Reason: 1
I would guess the dimness is a combination of only supplying 5V not 7.5 and also what current is each LED rated for? Cause like I mentioned previously it looked like 10k resistors which would only supply each LED with half a milliamp of current which seems way too low, but I'm not sure what is standard for those 7 segment displays?

A shift register will not boost power. Nor will a transistor (it will allows you switch on and off a higher voltage source but it doesn't generate that power for you, you need to have a 7.5 V adapter etc. ) .I suggest you go do some reading on each component and learn about them. There is a wealth of information online and on YouTube. And check the datasheets too!

Two links to start out with:

http://arduino.cc/en/tutorial/ShiftOut

https://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors/transistors
"I have not failed. I've just found 10,000 ways that won't work." - Thomas A. Edison

officialxian


I would guess the dimness is a combination of only supplying 5V not 7.5 and also what current is each LED rated for? Cause like I mentioned previously it looked like 10k resistors which would only supply each LED with half a milliamp of current which seems way too low, but I'm not sure what is standard for those 7 segment displays?


I pulled out the resistors, I had them in because I read somewhere that in this situation, it wouldn't matter what the resistance was. So I got them on (I think!) with no resistors. Also, I have no idea what current they're rated for. Like I said, they were bought (not by me) from a crappy China-based retailer on ebay. All the information I can find is barely relevant. Although, this seems to be for my SM4123-1 LEDs, and it says 5-10mA.

Thanks for the reference. I'll do some searching. I hope that I won't have to bother you guys anymore.

wes000000

Where did you read the current wouldn't matter? They may work a short time with no current limiting resistor, but I would guess you would burn out the LED segments very quickly with no current limit resistors.

If 5-10mA is your target, then put in resistors with values of 500 ohms or close to it.
"I have not failed. I've just found 10,000 ways that won't work." - Thomas A. Edison

Go Up