Plano, TX
Offline
Full Member
Karma: 0
Posts: 101
|
 |
« Reply #15 on: March 06, 2010, 12:28:39 am » |
I've used the STLED316S LED driver in several projects with good results. It's inexpensive and can drive up to 6 common anode digits plus 8 additional discrete LEDs with brightness control. It can also read from up to 16 tactile switches. I'm currently developing an alarm clock shield using this chip - I hope to post details soon. I've written a library for the chip I plan to share. It's only available in an SMT package but you could always put one on a breakout board if that's a problem.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 8
Arduino rocks
|
 |
« Reply #16 on: March 21, 2010, 05:47:43 pm » |
Can anyone please help me get hari's code working with my 4 digit 7 segment display? It is almost the same as sparkfun's except the pins are in a different configuration. Here is the pin configuration: 1-8 on bottom (left to right) 9-16 on top (right to left)  Thanks!
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 8
Arduino rocks
|
 |
« Reply #17 on: March 25, 2010, 09:25:06 pm » |
*bump*
|
|
|
|
|
Logged
|
|
|
|
|
Lincoln, NE
Offline
Full Member
Karma: 0
Posts: 103
Having lots of fun with Arduino. Thanks everyone!
|
 |
« Reply #18 on: March 25, 2010, 09:54:35 pm » |
Pinout is not the only difference. Your display is common Cathode and my SparkFun display is common Anode. So basically wherever the code sets pin to HIGH it needs to set it LOW and vice versa. I only had to make 4 changes to the code and I've highlighted them [glow]yellow[/glow]. That should work. Good luck! /* WAS: Testing SparkFun's 4-digit 7-Segment Display (Blue) NOW: Altered for GmDude66 for H.LTC.4727 */
int segmentA = 0; // Segments A thru P == pins 0 thru 7 int digit0 = 10; // Digits 3 thru 0 == pins 10 thru 13 (0 is LEFT most digit)
/* [glow]Change#1 Added wiring guide for your H.LTC.4727[/glow]
W I R I N G G U I D E
=== Common Cathode digits === Arduino Display Digit 10 1 0 Leftmost 11 2 1 12 6 2 13 8 3 Rightmost === Anode Segments === Arduino Display Segment 0 14 A 1 16 B 2 13 C 3 3 D 4 5 E 5 11 F 6 15 G */
/* 10 digits: Each defines which segments should be on/off for that digit: A,B,C,D,E,F,G,P */ byte numbers[10] = { B11000000, // 0 B11111001, // 1 B10100100, // 2 B10110000, // 3 B10011001, // 4 B10010010, // 5 B10000010, // 6 B11111000, // 7 B10000000, // 8 B10010000 // 9 };
void setup() { for (byte segment = 0; segment < 8; segment++) pinMode(segmentA+segment,OUTPUT);
for (byte digit = 0; digit < 4; digit++) pinMode(digit0+digit,OUTPUT); }
int perDigitTime = 100; int digitPosition = 1; // Start anywhere but zero so we won't crash when we try to turn off previous digit. unsigned long previousMillis = 0;
int value = 0; int powerOfTen[] = { 1,10,100,1000};
void RefreshDisplay() { [glow] //Change#2 (Your display is common Cathode, so to turn OFF a digit, we need to set it to +5)[/glow] digitalWrite(digit0 + digitPosition, [glow]HIGH[/glow]); // Turn off previous digit
digitPosition++; if (digitPosition > 3) digitPosition = 0;
int digitValue = value % powerOfTen[ digitPosition+1 ] / powerOfTen[digitPosition]; int number = numbers[ digitValue ]; if ((number > 0) || (value < powerOfTen[ digitPosition+1 ])) { for (byte seg = 0; seg < 8; seg++) digitalWrite(segmentA+seg, [glow]1 - [/glow]bitRead(number, seg) ); [glow]// Change#3 added "1-" to invert the bit for your common Cathode display[/glow]
digitalWrite(digit0 + digitPosition, [glow]LOW[/glow]); [glow]//Change#4 LOW will turn this digit on.[/glow] delay(4); } }
void loop() { unsigned long currentMillis = millis(); if (currentMillis - previousMillis > perDigitTime) { previousMillis = currentMillis; value++; }
RefreshDisplay(); }
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 8
Arduino rocks
|
 |
« Reply #19 on: March 26, 2010, 08:11:35 pm » |
Thank you!
The display works perfectly now!
One more question: how would I go about getting the colon to stay lit all the time?
EDIT: Just combined your code along with ninjamastr's code to get this display working with my 74HC595
|
|
|
|
« Last Edit: March 26, 2010, 09:00:26 pm by GmDude66 »
|
Logged
|
|
|
|
|
Lincoln, NE
Offline
Full Member
Karma: 0
Posts: 103
Having lots of fun with Arduino. Thanks everyone!
|
 |
« Reply #20 on: March 26, 2010, 09:14:28 pm » |
Thank you! The display works perfectly now! Awesome! Glad to be able to help. One more question: how would I go about getting the colon to stay lit all the time? I don't know. Sorry... :-[
|
|
|
|
|
Logged
|
|
|
|
|
SE USA
Offline
Faraday Member
Karma: 33
Posts: 3617
@ssh0le
|
 |
« Reply #21 on: March 27, 2010, 02:19:57 am » |
drink 1oz of hot sauce, followed by 4 fingers of whiskey I promise your colon will be lit up full time for quite a while 
|
|
|
|
|
Logged
|
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 27
Arduino rocks
|
 |
« Reply #22 on: March 27, 2010, 10:42:14 am » |
zink0xide, As others have mentioned, you can use practically any 8-bit serial-to-parallel 'sinking' driver IC or "constant current" sinking driver IC connected to the segments and five PNP or P-channel MOSFET 'sourcing' column drivers. The 74HC595 is a little "light duty" for this application but seems to hold up well. A better choice might be the TPIC6C595. Here's an example of my MacMux design for that Sparkfun display. I apologize for not yet having enough experience to back up the design with an Arduino software driver example but I could provide a C example for PIC if someone wants to take a stab at coding my method for Arduino. The MacMux design uses the PWM module with a period equal to the digit scan interval (1 to 2 msecs) to multiplex the column driver lines. When the PWM signal goes high (display "off") at the beginning of each digit scan interval the column driver lines are re-tasked for use as <CLK> and <DAT> lines to load the 74HC595 shift register. The column driver lines are then reset to the correct column select pattern (only one line low) before the PWM line goes back low (display "on"). Complete fade-to-black brightness control is a matter of setting the PWM duty cycle to some value between approximately 5% and 100% in the main program. PWM duty cycle is inversely proportional to display brightness with a 5% duty cycle = full brightness and a 100% duty cycle = black. Regards, Mike 
|
|
|
|
« Last Edit: March 27, 2010, 01:19:50 pm by Mike-K8LH »
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 0
Posts: 128
Arduino rocks
|
 |
« Reply #23 on: June 21, 2010, 01:37:14 pm » |
I was just wondering how to program the Arduino to make the 4 digit 7-segment display show a number that was arrived at in a different part of the program. I would be using the red display, so would it be different than Hari's post? I think I may have to use an Arduino Mega since I'm already taking up 8 digital pins with other things.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 2
Arduino rocks
|
 |
« Reply #24 on: July 12, 2010, 11:02:03 am » |
just a quick comment. 4 resistors are enough, and the 40ma is not a real issue (only 4 segments can be using the same current source, and with 10ma you can still get good brightness) if using the code from " http://nootropicdesign.com/projectlab/2009/10/" (mentioned by jeremytsl). in this code the relevant segments are turned on individually, and stays on for a short delay, and then turned off. this also answers the question embedded in the code for why there is a need for a delay. "delay(1); // Don't understand why I Have to set a delay digitalWrite(groundPins[g], HIGH);" also, if using the red 7-segment display, which is rated 2.1V and 20ma a 330 or 220 Ohm resistors are better. if using a code that lights all the segments in a number at the same time - then the comments are accurate and segments should each have a resistor and 40ma Arduino pin output should be taken under consideration. thanks everyone for your comments!
|
|
|
|
« Last Edit: July 12, 2010, 01:26:57 pm by alobar »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 6
Arduino rocks
|
 |
« Reply #25 on: August 03, 2010, 12:42:56 am » |
Hi all, my apology if this belong in a separate thread. I just received this (YSD-439AK2B-35) from sparkfun and started playing with it. What I realize is that if I set this to input on HIGH, it uses lower voltage (1.74v). And I tested it out with 1k resistors, which is the smaller I have ATM, it will lid up but very dim (w/ 1k R). I'm too chicken too remove the resistor, since its brand new... So what I want to know is, can I cut the cost down and save a few resistors this way? The specs say Reverse voltage: VR=5V, 10µA and this is the code I used to test it. void setup() { pinMode(13, INPUT); digitalWrite(13, HIGH); pinMode(2, OUTPUT); }
void loop() { digitalWrite(2, LOW); delay(1000); digitalWrite(2, HIGH); delay(1000); }
Thanks.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 6
Arduino rocks
|
 |
« Reply #26 on: August 03, 2010, 01:06:59 am » |
nm.... forgot about internal resistors on pin13...
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Faraday Member
Karma: 17
Posts: 3895
Arduino rocks
|
 |
« Reply #27 on: October 10, 2010, 03:34:55 am » |
Hi Hari,
i used your modified code for Common Cathode display, but the digit is inverted, i have the millisecond number on the left and the other number to the right.
Maybe the problem is your note //Digits 3 thru 0 == pins 10 thru 13 (0 is LEFT most digit)
i Think that the right is //Digit 0 thru 3 == pins 10 thru 13 but i don't know how change this in the sketch.
thanks for your attention
--------------------- Posted by: hari Posted on: 26.03.2010 at 04:54:35 Pinout is not the only difference. Your display is common Cathode and my SparkFun display is common Anode. So basically wherever the code sets pin to HIGH it needs to set it LOW and vice versa. I only had to make 4 changes to the code and I've highlighted them yellow. That should work. Good luck!
|
|
|
|
|
Logged
|
|
|
|
|
Lincoln, NE
Offline
Full Member
Karma: 0
Posts: 103
Having lots of fun with Arduino. Thanks everyone!
|
 |
« Reply #28 on: October 10, 2010, 10:23:15 am » |
Testato, If I understand you correctly, it is probably simplest to adjust the wiring rather than the code. Take a look at Arduino pins 10,11,12,13. Those corresponds to the digits. Say right now you have it wired like this: | Arduino | Display | | 10 | P | | 11 | Q | | 12 | R | | 13 | S |
You have complete control as to which digit value correspond to which display digit. What if you re-wire it like this? | Arduino | Display | | 13 | P | | 12 | Q | | 11 | R | | 10 | S |
Good luck!
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Faraday Member
Karma: 17
Posts: 3895
Arduino rocks
|
 |
« Reply #29 on: October 10, 2010, 11:26:30 am » |
yes i know, it work, but i would understand wich is the way for correct the code, because is the code incorrect not the connection.
it is only for understand.
|
|
|
|
|
Logged
|
|
|
|
|
|