Go Down

Topic: 4 Digit 7 Segment Serial LED Module - TM74HC595 (Read 39423 times) previous topic - next topic

blahop

@NickGammon thanks for the links!

(I may be wrong but it seems that the first link is "only the 7segment display", not with the MAX7219).

What I would need now is a kit (presoldered or not presoldered) with : MAX7219 + board (for 4 digits only) + 4digits 7segment display.

The 8digit board won't fit in my enclosure...

Any idea?

nickgammon

Search eBay? Something like this:

http://www.ebay.com/itm/I2C-4-Digit-7-Seven-Segment-Display-Arduino-uController-5V-Choose-Red-or-Green-/231556862719 That's $8 rather than $3, but you don't always find exactly what you want. Or get one of the 8-digits ones which are not assembled and just not solder on the second 4-digit LED module.
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

Mitschgel

So has anyone an answer to my question from page 5?
Thanks a lot!

@aarg: I have one question remaining.
The project I'm currently working on is basically a DMX controlled Infrared Remote.
(DMX Reception and sending Infrared Commands is already working great, but I wanted to add the 7segment display to show the current DMX Adress of my Device.)

The DMX signal reception is using Timer2 ( for reference: the DMX code can be found here:  receive-dmx-512-with-an-arduino)
and i have successfully added my 7segment display with your micros() based code.

Since I have unfortunately not much experience with arduino programming and all the timer based ISR stuff is a bit confusing, too...
is it advisable to leave the 7segment display output micros() based or should one better be working with your new timer2 based code?

In this case, I guess that I would have to switch your code from timer2 to timer1,
which I already tried (out of curiosity) and failed totally at :D

aarg

So has anyone an answer to my question from page 5?
Thanks a lot!

I am just learning the timers. But it seems to me, it must be easy to change to timer 1 from timer 2. I will investigate and post a solution if I find it.
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

aarg

#79
May 18, 2015, 09:13 am Last Edit: May 18, 2015, 12:08 pm by aarg
@Mitschgel. Okay, here is a version that will work with either timer 1 or timer 2. There's a #define variable near the top, you just set it to 1 or 2 to choose the timer.
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

Mitschgel

wow, thanks a lot
that is just awesome! I'll try to implement it in my project and will let you know how it goes.

thx again for your effort!

2leon76

Hi,

What about 8 digit display based on 595 chip?

I have found code below -

Code: [Select]

#define LATCH  12  //pin 12 of BBFuino connect to RCK of 8x7segment module
#define CLOCK  11  //pin 11 of BBFuino connect to SCK of 8x7segment module
#define DATA   10  //pin 10 of BBFuino connect to DIO of 8x7segment module
#define LED    13  //LED is connected to pin 13 of Arduino
#define  MultiplexDelay  1  //delay for multiplexing between digit on 8x7segment module
#define LEFT   0  // define the value for left justify
#define RIGHT  1  // define the value for right justify
#define BLANK 11  //array element to make 7segment blank


// array to activate particular digit on the 8x7segment module
// it is the common anode of 7 segment
byte anode[8] = { 0b10000000,  //digit 1 from right
                    0b01000000,  //digit 2 from right
                    0b00100000,  //digit 3 from right
                    0b00010000,  //digit 4 from right
                    0b00001000,  //digit 5 from right
                    0b00000100,  //digit 6 from right
                    0b00000010,  //digit 7 from right
                    0b00000001   //digit 8 from right                                        
                    };

//array for decimal number, it is the cathode, please refer to the datasheet.
//therefore a logic low will activete the particular segment
                    //PGFEDCBA, segment on 7 segment, P is the dot
byte cathode[12] = {0b11000000,  // 0
                    0b11111001,  // 1
                    0b10100100,  // 2
                    0b10110000,  // 3
                    0b10011001,  // 4
                    0b10010010,  // 5
                    0b10000010,  // 6
                    0b11111000,  // 7
                    0b10000000,  // 8
                    0b10010000,  // 9  
                    0b01111111,  //dot                  
                    0b11111111   //blank
                    };    
 
//fucntion to send the serial data out to two 74HC595 serial to parallel shift register and activate the 7 segment.                  
void display8x7segment(byte datapin, byte clockpin, byte latchpin, byte digit, byte number)
{
    digitalWrite(latchpin, LOW);
    shiftOut(datapin, clockpin, MSBFIRST, digit); // clears the right display
    shiftOut(datapin, clockpin, MSBFIRST, number); // clears the left display
    digitalWrite(latchpin, HIGH);  
}

//function to display value on 8x7 segment display according to the justify state
void displayNumber8x7segment(byte justify, unsigned long value)
{

   byte decimal[8] = {0};  
   value = value % 100000000;  //ensure the value is within 8 digits only
   decimal[7] = value / 10000000;  //extract digit 7 from value
   value = value % 10000000;       //extract the rest of 7 digit value
   decimal[6] = value / 1000000;
   value = value % 1000000;
   decimal[5] = value / 100000;
   value = value % 100000;
   decimal[4] = value / 10000;
   value = value % 10000;
   decimal[3] = value / 1000;
   value = value % 1000;
   decimal[2] = value / 100;
   value = value % 100;
   decimal[1] = value / 10;
   decimal[0] = value % 10;
   byte zero = 0;
   if (justify == RIGHT)
   {  
     for(byte e = 8; e > 0 ; e --)
     {
       if(zero == 0)
       {
         if(decimal[e-1] != 0)          
         {
           display8x7segment(DATA, CLOCK, LATCH, anode[e-1], cathode[decimal[e-1]]);
           zero = 1;    
         }
       }
       else display8x7segment(DATA, CLOCK, LATCH, anode[e-1], cathode[decimal[e-1]]);
    
     delay(MultiplexDelay);
     }
   }
   else  //if justify == left
   {
     byte d = 0;    
     for(byte e = 8; e > 0; e --)
     {      
       if(zero == 0)
       {
         if(decimal[e-1] != 0)        
         {
           display8x7segment(DATA, CLOCK, LATCH, anode[7], cathode[decimal[e-1]]);
           zero = 1;
           d ++;    
           delay(MultiplexDelay);
         }
       }
       else
       {
         display8x7segment(DATA, CLOCK, LATCH, anode[7-d], cathode[decimal[e-1]]);
         d ++;
         delay(MultiplexDelay);
       }    
      
     }
    
   }
}
 
void setup() {
  pinMode(LATCH, OUTPUT);
  pinMode(CLOCK, OUTPUT);
  pinMode(DATA, OUTPUT);
  pinMode(LED, OUTPUT);
  digitalWrite(LATCH, HIGH);  
  digitalWrite(LED, LOW);  //off LED  
  // set up the LCD's number of columns and rows:
 
  delay(1000);  //delay for 1 second
  
}

void loop(){
  
  //1st demo, 8x7segment will display decimal value from 0 to 9 and dot from 1st digit (most right) until the last digit (most right)
  for(byte i = 0; i < 8; i++)
  {
    for(byte k = 0; k < 11; k++)
    {
       display8x7segment(DATA, CLOCK, LATCH, anode[i], cathode[k]);  
    
       delay(300);
    }
  }  
  delay(1000);  //delay 1 second
  
  //2nd demo, 8x7segment will display same decimal from 0 to 9 and dot across all 8 digit
  for(byte k = 0; k < 11; k++)
    {    
        display8x7segment(DATA, CLOCK, LATCH, 0xff, cathode[k]);  //activate all digit  
  
        delay(300);    
    }  
  delay(1000);  //delay 1 second
  
  //3rd demo, 8x7segment will display a decimal value increasing like normal counter.
  for (unsigned long value = 0; value < 100000000; value ++)
  {    
     for(byte i = 0; i < 10 ; i ++)
      {
  
      displayNumber8x7segment(RIGHT, value);  //display the value in right justify format    
     }      
  }
  delay(1000);
  
}

407charlie

  I'm trying to get the datasheet but without success. Would you mind to shear it with me?

aarg

#83
Jan 17, 2016, 02:56 pm Last Edit: Jan 17, 2016, 03:00 pm by aarg
What a crazy hijack! Not even a mention of what hardware. And then it gets a response! Oy!
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

Oliver0nArduino

Thank you aarg, for your research on this and your code. Here is my small contribution, please excuse my style, these were the first lines that I wrote in this environment. :)

It allows one to display a rational number within certain limits


Code: [Select]
int getFullNumberAndCountDecimals(float fNumber, int* decimals){
   *decimals = 0;
   float tempNumber = fNumber;
   
   while (tempNumber != trunc(tempNumber)){
    tempNumber *= 10;
    *decimals+=1;
   }
   
   //TODO ignore last digits for numbers that don't fit (like 88.222)
   
   return tempNumber;
}


void printRational(float value){
 
 int countDecimals;
 int fullNumber = getFullNumberAndCountDecimals(value, &countDecimals);

 modulePrint2(fullNumber,10,testDigits);
 testDigits[(numDigits-1)-countDecimals]|= 0x80;  
}



One can use it by calling printRational with the desired value.

nickgammon

These last few posts seem completely off topic to me. What are you thinking of?
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

nickgammon

I think I'll close this thread before someone starts talking about how to cook chickens. ;)
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

Go Up