8 x 7 Segment Display 3461BS

11.06.2014
Minor Update – count up (with deciaml dot or be variable!)

 

2014-06-11 18.40.59       2014-06-11 18.42.25

To count up and using a decimal dot, we must change the source code only a little bit. We need an additional variable (named valued[]) to store the digits with decimal dot.
And the second supplement is an IF statement to select the number with decimal dot.
That’s all!

Please, use the source code below (date 01.06.2014 with the following supplements!
Here is the first supplement – the new variable valued[] (the supplement is bold):

byte value[] ={ B11111001, // 1
                B10100100, // 2
                B10110000, // 3
                B10011001, // 4
                B10010010, // 5
                B10000010, // 6
                B11111000, // 7
                B10000000, // 8
                B10010000, // 9
                B11000000, // 0
                B11111111};// display nothing

byte valued[] ={ B01111001, // 1.
                 B00100100, // 2.
                 B00110000, // 3.
                 B00011001, // 4.
                 B00010010, // 5.
                 B00000010, // 6.
                 B01111000, // 7.
                 B00000000, // 8.
                 B00010000, // 9.
                 B01000000, // 0.
                 B11111111};// display nothing

and the other supplement – the IF statement:

  digitalWrite(latch,LOW);
  shiftOut(data,clock,MSBFIRST,B11111111);
  shiftOut(data,clock,MSBFIRST,B11111111);
  digitalWrite(latch,HIGH); 

  digitalWrite(latch,LOW);
  shiftOut(data,clock,MSBFIRST,digit[ii]);
  // define decimal place
  if (ii==5) 
    shiftOut(data,clock,MSBFIRST,valued[vvalue]);
  else 
    shiftOut(data,clock,MSBFIRST,value[vvalue]);
  digitalWrite(latch,HIGH);

 

To change the position of the decimal dot, change the value inside the IF statement. In example, ii==6 means, xxxxxxx.x
ii==3 means, xxxx.xxxx


 

 

01.06.2014
Update – count up!

I show you a simple code sample, how you can use the 8×7 segment display to count up.
I use the same procedure, I changed the loop section only.

 

2014-06-01 16.26.56 2014-06-01 16.34.24

const int clock = 7; //SCK
const int latch = 5; //RCK 
const int data = 6;  //DIO

byte value[] ={ B11111001, // 1
                B10100100, // 2
                B10110000, // 3
                B10011001, // 4
                B10010010, // 5
                B10000010, // 6
                B11111000, // 7
                B10000000, // 8
                B10010000, // 9
                B11000000, // 0
                B11111111};// display nothing

byte digit[] ={ B00000001, // left segment
                B00000010,
                B00000100,
                B00001000,
                B00010000,
                B00100000,
                B01000000,
                B10000000}; // right segment

byte ii = 0;

byte v0, v1,v2,v3,v4,v5,v6,v7;
byte vvalue = value[0];
 
void setup() {
  pinMode(clock, OUTPUT);
  pinMode(latch, OUTPUT);
  pinMode(data, OUTPUT);
  
  cli();//stop interrupts
  //set timer0 interrupt at 980Hz
  TCCR0A = 0;// set entire TCCR0A register to 0
  TCCR0B = 0;// same for TCCR0B
  TCNT0  = 0;//initialize counter value to 0
  OCR0A = 255;//(must be <256) --> 16000000 / (prescaler*255) = 980 Hz
  TCCR0A |= (1 << WGM01);
  TCCR0B |= (1 << CS01) | (1 << CS00);   //prescaler = 64
  TIMSK0 |= (1 << OCIE0A);  
  sei();//allow interrupts
  
  v0=v1=v2=v3=v4=v5=v6=v7=0;  
}
 


ISR(TIMER0_COMPA_vect){   
  ii++;
  if (ii==8) ii=0;

  if (ii==0) { vvalue = v0; }
  else if (ii==1) { vvalue = v1; }    
  else if (ii==2) { vvalue = v2; }
  else if (ii==3) { vvalue = v3; }
  else if (ii==4) { vvalue = v4; }
  else if (ii==5) { vvalue = v5; }
  else if (ii==6) { vvalue = v6; }
  else if (ii==7) { vvalue = v7; }

  digitalWrite(latch,LOW);
  shiftOut(data,clock,MSBFIRST,B11111111);
  shiftOut(data,clock,MSBFIRST,B11111111);
  digitalWrite(latch,HIGH); 

  digitalWrite(latch,LOW);
  shiftOut(data,clock,MSBFIRST,digit[ii]);
  shiftOut(data,clock,MSBFIRST,value[vvalue]);
  digitalWrite(latch,HIGH);   
}


long i;

void loop() {

  for (i=1;i<=99999999;i++) {
   v7 = i % 10;
   v6 = (i / 10) % 10;
   v5 = (i / 100) % 10;
   v4 = (i / 1000) % 10;
   v3 = (i / 10000) % 10;
   v2 = (i / 100000) % 10;
   v1 = (i / 1000000) % 10;
   v0 = (i / 10000000) % 10;
   delay(30);
  }
}

 

 

 

12.03.2014
Update – Show different numbers at different digits

Now, we need a modification of our source code. We want to display different numbers at different digits. Yes, it’s possible. To do this, we need a timer interrupt.
This is the basic workflow:
Select a digit, send a number. Each time, we select only one digit, not all digits at the same time!
We select the first digit and send a number. Than, we select the second digit and send a different number. Than, we select the third digit (and send the number), than the fourth digit, … and the eigth digit. After this, we start with the first digit again.

You will see, I use two additional steps. Before I select a digit, I select all digits and send “nothing”. So I don’t have a flicker.

There is one question to answer: How often should I change the digit per second.
We need more than 28 times per second the display at each digit. Than the human eyes don’t register a flicker.
We calculate: 28 times per second … we have 8 digits … the result is: 224 Hz (28 * 8).

The source code:

const int clock = 7; //SCK
const int latch = 5; //RCK 
const int data = 6;  //DIO

byte value[] ={ B11111001, // 1
                B10100100, // 2
                B10110000, // 3
                B10011001, // 4
                B10010010, // 5
                B10000010, // 6
                B11111000, // 7
                B10000000, // 8
                B10010000, // 9
                B11000000, // 0
                B11111111};// display nothing

byte digit[] ={ B00000001, // left segment
                B00000010,
                B00000100,
                B00001000,
                B00010000,
                B00100000,
                B01000000,
                B10000000}; // right segment

byte ii = 0;

byte v0, v1,v2,v3,v4,v5,v6,v7;
byte vvalue = value[0];

void setup() {
  pinMode(clock, OUTPUT);
  pinMode(latch, OUTPUT);
  pinMode(data, OUTPUT);

  cli();//stop interrupts
  //set timer0 interrupt at 980Hz
  TCCR0A = 0;// set entire TCCR0A register to 0
  TCCR0B = 0;// same for TCCR0B
  TCNT0  = 0;//initialize counter value to 0
  OCR0A = 255;//(must be  16000000 / (prescaler*255) = 980 Hz
  TCCR0A |= (1 << WGM01);
  TCCR0B |= (1 << CS01) | (1 << CS00);   //prescaler = 64
  TIMSK0 |= (1 << OCIE0A);  
  sei();//allow interrupts

  v0=v1=v2=v3=v4=v5=v6=v7=10; // default: show nothing 
}

ISR(TIMER0_COMPA_vect){   
  ii++;
  if (ii==8) ii=0;

  if (ii==0) { vvalue = v0; }
  else if (ii==1) { vvalue = v1; }    
  else if (ii==2) { vvalue = v2; }
  else if (ii==3) { vvalue = v3; }
  else if (ii==4) { vvalue = v4; }
  else if (ii==5) { vvalue = v5; }
  else if (ii==6) { vvalue = v6; }
  else if (ii==7) { vvalue = v7; }

  digitalWrite(latch,LOW);
  shiftOut(data,clock,MSBFIRST,B11111111);
  shiftOut(data,clock,MSBFIRST,B11111111);
  digitalWrite(latch,HIGH); 

  digitalWrite(latch,LOW);
  shiftOut(data,clock,MSBFIRST,digit[ii]);
  shiftOut(data,clock,MSBFIRST,value[vvalue]);
  digitalWrite(latch,HIGH);   
}

int a, b,t,d;

void loop() {;
 b = random(0,11);     // value to display
 t = random(25,100);   // time to count
 d = random(0,8);      // digit to change

 switch (d) {
   case 0:
     for (a=0;a<=b;++a) {v0 = a;  delay(t);}
     break;
   case 1:
     for (a=0;a<=b;++a) {v1 = a;  delay(t);}
     break;
   case 2:
     for (a=0;a<=b;++a) {v2 = a;  delay(t);}
     break;
   case 3: 
     for (a=0;a<=b;++a) {v3 = a;  delay(t);}
     break;    
   case 4:
     for (a=0;a<=b;++a) {v4 = a;  delay(t);}
     break;
   case 5:
     for (a=0;a<=b;++a) {v5 = a;  delay(t);}
     break;
   case 6:
     for (a=0;a<=b;++a) {v6 = a;  delay(t);}
     break;
   case 7:
     for (a=0;a<=b;++a) {v7 = a;  delay(t);}
     break;
   default:
     v0=v1=v2=v3=v4=v5=v6=v7=10;
     break;    
 }
}

Hi,

today I show you in this tutorial, how this module work and how you must design your source code.

First I show you my modules:

IMAG0197_1 IMAG0198

You see, we need 5 pins zu connect the module. Vcc, GND, DIO, SCK and RCK. Later more.
In order to recognize, how we can use the display, we need the knowledge about the ICs.

There are two 74HC595D. The 74HC595D is an 8 Bit Serial In Shift Register. It means, we need only one data pin for the Input.

So we have:
Vcc = 3.3V (it’s possible to use 5V too, but it will be better to use only 3.3V)
GND = Ground
DIO = Serial Data Input
SCK = Serial Clock Input
RCK = Serial Latch

How does it works?
We have two ICs, so we need also two Byte as Input. With the first Input Byte we select the segment we want to use. The secondary Input Byte describe the digit we want to display.

Our Arduino has a special command to work with a Shift Register. It’s “shiftout“. This command sends one Byte serial to DIO (Data pin). We must only determine, how is built up our Byte.
I use “MSBFirst”. This is the abreviation for “Most Signifikant Bit first”.

const int clock = 7; //SCK
const int latch = 5; //RCK 
const int data = 6;  //DIO

byte value[] ={ B11111001, // 1
                B10100100, // 2
                B10110000, // 3
                B10011001, // 4
                B10010010, // 5
                B10000010, // 6
                B11111000, // 7
                B10000000, // 8
                B10010000, // 9
                B11000000, // 0
                B11111111};// display nothing

byte digit[] ={ B00000001, // left segment
                B00000010,
                B00000100,
                B00001000,
                B00010000,
                B00100000,
                B01000000,
                B10000000}; // right segment
void setup() {
  Serial.begin(9600);
  pinMode(clock, OUTPUT);
  pinMode(latch, OUTPUT);
  pinMode(data, OUTPUT);
}

void loop() {;
  digitalWrite(latch,LOW);
  shiftOut(data,clock,MSBFIRST,B11111111); // select all segments
  shiftOut(data,clock,MSBFIRST,B11111111); // display nothing
  digitalWrite(latch,HIGH); 

  digitalWrite(latch,LOW);
  // select the fourth segment from left
  shiftOut(data,clock,MSBFIRST,digit[3]);  
  // show the digit "5" ( the array starts with 0 to count!)
  shiftOut(data,clock,MSBFIRST,value[4]);  
  digitalWrite(latch,HIGH);
}

And this is the result:
IMAG0200
Is it possible to display more digits at the same time?
Yes, it is!

  
  digitalWrite(latch,LOW);
  // select more segments to activate
  shiftOut(data,clock,MSBFIRST,B01010101);
  shiftOut(data,clock,MSBFIRST,value[4]);
  digitalWrite(latch,HIGH);

The result:

IMAG0201

Is it possible to display different numbers at the same time like below?
Yes, but not with this source code.

Don’t forget, we have only two Bytes. The first Byte selects the segment, the second Byte creates the number. Only One byte – only one number!
But there is a trick – we select the first segment and write the number, than we select the next segment and write another number, etc. The trick is, we do this so quickly, that our eyes don’t register that we do this not at the same time.

In the next days I will update this tutorial with the source code.

IMAG0202

Annotations:
I saw one of this modules by twitter. And I thought, it’s great to have some of this. I got my modules from the other side of the world, without informations about. It’s difficult to get correct informations about this modules. I found different datasheets with different informations. You can order the 3461BS element nativ. Possible you get a HLX3461BS, or a HS-3461BS, or similar. I found a wayjun datasheet with good information – questionable the value about the power consumtion. Each segment needs 30 mA. Both together are 60 mA. Our Arduino has only 50 mA! The other information in the datasheet is about the voltage. The wayjun modules works with 2.4 V … 3 V. So it will be safer to use only 3.3V from the Arduino.


13 thoughts on “8 x 7 Segment Display 3461BS

  1. Thank you for this valuable information. Can you upload some code that will make it count up form 0

      1. Thanks for this information can you upload code for pulse counter with arduino & yl-3 display

    1. Just put the line byte value line of 0 on top, like this:

      byte value[] ={ B11000000, // 0
      B11111001, // 1
      B10100100, // 2
      B10110000, // 3
      B10011001, // 4
      B10010010, // 5
      B10000010, // 6
      B11111000, // 7
      B10000000, // 8
      B10010000, // 9
      B11111111};// display nothing

  2. Pingback: playground2014
  3. Great tutorial!
    How can I easily disolay the readouts of my SFR02 Sonar on that display? Any approcahes?
    I did it with an LCD 16×2….

  4. Thank You for this. I just got this display and I would have never figured it out otherwise…at least it would have taken much longer!

  5. Thank you for this, there is barely any information out there on this display. I was wondering if it’s possible to make a 24 hour clock, that displays hours, minutes and seconds like this: hh-mm-ss, with the dashes being actual dashes on the display? I’m a noob on this subject so I hope I’m not asking dumb questions.

Leave a comment