Go Down

Topic: re help 8 digit seven segment display (Read 628 times) previous topic - next topic

uno_dos

anyone who can help us with creating codes with arduino uno in displaying number to an 8 digit seven segment display using 74hc595 ic.

uno_dos

#1
Feb 10, 2017, 01:55 am Last Edit: Feb 10, 2017, 02:01 am by uno_dos
Pls help us in modifying the code we just copied at http://www.circuitstoday.com/arduino-and-7-segment-display  . This code is to display four digit. And our problem is We want this code to  display an 8 digit cathode seven segment display. What must be added in the codes .here is the full code that we copied. Credits to the owner. Thank you


#include "Timer.h" //include timer library


Timer t; // craete a timer object
long number = 0; //declear the variables
int first_digit = 0;
int second_digit = 0;
int third_digit = 0;
int fourth_digit = 0;
int timer_event = 0;
int CA_1 = 12;
int CA_2 = 11;
int CA_3 = 10;
int CA_4 = 9;
int clk = 6;
int latch = 5;
int data = 4;
int count = 0;
int digits[4] ;
int CAS[4] = {12, 11, 10, 9};
byte numbers[10] {B11111100, B01100000, B11011010, B11110010, B01100110, B10110110, B10111110, B11100000, B11111110, B11110110};
//byte combinations for each number 0-9
void setup() {
 Serial.begin(9600); //serial start and pin config
 pinMode(CA_1, OUTPUT);
 pinMode(CA_2, OUTPUT);
 pinMode(CA_3, OUTPUT);
 pinMode(CA_4, OUTPUT);
 pinMode(clk, OUTPUT);
 pinMode(latch, OUTPUT);
 pinMode(data, OUTPUT);
 digitalWrite(CA_1, HIGH);
 digitalWrite(CA_2, HIGH);
 digitalWrite(CA_3, HIGH);
 digitalWrite(CA_4, HIGH);
 Serial.println("please Enter a number from 0 to 9999");
}

void loop() {
 t.update(); //timer update
 if (Serial.available()) { // read from serial
   t.stop(timer_event); //stop timer if anythign to read
   cathode_high(); // blank the screen
   String s = Serial.readString(); //read the serail value
   number = (long)s.toInt(); //convert it to int
   if (number > 9999) { //check the number is 0-9999
     Serial.println("Please Enter Number Between 0 - 9999");
   } else {
     break_number(number);
     timer_event = t.every(1, display_number); // start timer again
   }

 }

}

void break_number(long num) { // seperate the input number into 4 single digits

 first_digit = num / 1000;
 digits[0] = first_digit;

 int first_left = num - (first_digit * 1000);
 second_digit = first_left / 100;
 digits[1] = second_digit;
 int second_left = first_left - (second_digit * 100);
 third_digit = second_left / 10;
 digits[2] = third_digit;
 fourth_digit = second_left - (third_digit * 10);
 digits[3] = fourth_digit;

}

void display_number() { //scanning

 cathode_high(); //black screen
 digitalWrite(latch, LOW); //put the shift register to read
 shiftOut(data, clk, LSBFIRST, numbers[digits[count]]); //send the data
 digitalWrite(CAS[count], LOW); //turn on the relevent digit
 digitalWrite(latch, HIGH); //put the shift register to write mode


 count++; //count up the digit
 if (count == 4) { // keep the count between 0-3
   count = 0;
 }


}

void cathode_high() { //turn off all 4 digits

 digitalWrite(CA_1, HIGH);
 digitalWrite(CA_2, HIGH);
 digitalWrite(CA_3, HIGH);
 digitalWrite(CA_4, HIGH);
}

6v6gt

Can you provide a link to the (common cathode? ) display you will be using.
Apparently, you can use only one shift register 74hc595 , based on what you have written in another thread: https://forum.arduino.cc/index.php?topic=76883.msg3123500#msg3123500  #21 .
In your design, is this shift register intended to drive the anodes (segments) or the cathodes ?

uno_dos

hello sir we already solve it sir. But there is now changes,we will not be using ic anymore. because we will use a 5inch display. the ic is already built in with the seven segment display . Heres the link sir of that 5 inch display is im saying.

http://www.e-gizmo.com/oc/index.php?route=product/product&product_id=20

what is now our problem sir is what we will be changing in the codes on hhow to call what is the first digit. By the way sir we will use 8 digit of seven segment. Thank you sir for your respond.

AWOL

Are we, perhaps, going for a new record of threads started on the same topic?

Threads merged.

DO NOT CROSS-POST, CROSS-POSTING WASTES TIME.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

Go Up