Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using the schematic below, with a shift register and a 7 segment 4 digit display

ID: 3597933 • Letter: U

Question

Using the schematic below, with a shift register and a 7 segment 4 digit display(common cathode). Use the serial port to read an integer value. The range of numbers is [0,9999]. Display the value on the seven segment display.

Here is some starter code I am working with that has the display cycleing through intigers.

int latch=9; //74HC595 pin 9 STCP
int clock=10; //74HC595 pin 10 SHCP
int data=8; //74HC595 pin 8 DS

unsigned char table[]=
{0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c
,0x39,0x5e,0x79,0x71,0x00};

void setup() {
pinMode(latch,OUTPUT);
pinMode(clock,OUTPUT);
pinMode(data,OUTPUT);
}
void Display(unsigned char num)
{

digitalWrite(latch,LOW);
shiftOut(data,clock,MSBFIRST,table[num]);
digitalWrite(latch,HIGH);
  
}
void loop() {
Display(1);
delay(500);
Display(2);
delay(500);
Display(3);
delay(500);
Display(4);
delay(500);
Display(5);
delay(500);
Display(6);
delay(500);
Display(7);
delay(500);
Display(8);
delay(500);
Display(9);
delay(500);
Display(10);
delay(500);
Display(11);
delay(500);
Display(12);
delay(500);
Display(13);
delay(500);
Display(14);
delay(500);
Display(15);
delay(500);
}

UNO R3 74HC595

Explanation / Answer

int latch=9; //74HC595 pin 9 STCP

int clock=10; //74HC595 pin 10 SHCP

int data=8; //74HC595 pin 8 DS

unsigned char table[]=

{0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c

,0x39,0x5e,0x79,0x71,0x00};

void setup() {

pinMode(latch,OUTPUT);

pinMode(clock,OUTPUT);

pinMode(data,OUTPUT);

}

void Display(unsigned char num)

{

digitalWrite(latch,LOW);

shiftOut(data,clock,MSBFIRST,table[num]);

digitalWrite(latch,HIGH);

  

}

int main(){

int i;

for(i=0;i<1000;i++){

Display(i);

delay(500);

}

}

/*

void loop() {

Display(1);

delay(500);

Display(2);

delay(500);

Display(3);

delay(500);

Display(4);

delay(500);

Display(5);

delay(500);

Display(6);

delay(500);

Display(7);

delay(500);

Display(8);

delay(500);

Display(9);

delay(500);

Display(10);

delay(500);

Display(11);

delay(500);

Display(12);

delay(500);

Display(13);

delay(500);

Display(14);

delay(500);

Display(15);

delay(500);

}

*/