i build new type stopwatch with 2, 7 segment display with 5 digit.my problem is how to display the both display with same number.i try add the output,that mean the data,clock and lath output have double pin.but it can't work.let see the code.
////////////////////////////////////
unsigned long currentmicros = 0;
unsigned long previousmicros = 0;
unsigned long interval = 1000;
unsigned long elapsedmicros = 0;
byte trigger = 2;
byte started = 0;
byte stopped = 0;
byte latchpin = 7, 8; // connect to pin 12 on the 74HC595
byte clockpin = 6, 12; // connect to pin 11 on the 74HC595
byte datapin = 5, 11; // connect to pin 14 on the 74HC595
int ones_seconds = 0;
int tens_seconds = 0;
int ones_minutes = 0;
int tens_minutes = 0;
int tenths = 0;
int hundredths= 0;
int thousandths = 0;
byte inPinstat;
int segdisp[10] = {
63,6,91,79,102,109,125,7,127,111 }; //segment references using 74HC595 Shift Registers
//The above numbers light up different segments of a digit
int time_update = 0;// added new flag
void setup()
{
Serial.begin(115200);
pinMode(latchpin, OUTPUT);
pinMode(clockpin, OUTPUT);
pinMode(datapin, OUTPUT);
pinMode(trigger, INPUT);////stat/stop.
digitalWrite(latchpin, LOW); // send the digits down to the shift registers!
shiftOut(datapin, clockpin, MSBFIRST, segdisp[tens_seconds]);
shiftOut(datapin, clockpin, MSBFIRST, segdisp[ones_seconds]);
shiftOut(datapin, clockpin, MSBFIRST, segdisp[tenths]);
shiftOut(datapin, clockpin, MSBFIRST, segdisp[hundredths]);
shiftOut(datapin, clockpin, MSBFIRST, segdisp[thousandths]);
digitalWrite(latchpin, HIGH);
}
void loop()
{
inPinstat = digitalRead(trigger);
if(inPinstat == HIGH)
{
currentmicros = micros(); // read the time.
elapsedmicros = currentmicros - previousmicros;
if (elapsedmicros >= interval) // 10 milliseconds have gone by
{
previousmicros = previousmicros + elapsedmicros; // save the time for the next comparison
time_update = 1; // set flag to shift out the new time
}
if (time_update == 1){ // no updating if not at 10ms interval, skip this whole section
// increment the counters, roll as needed, shift the digits out
time_update = 0; // reset for next pass thru
thousandths = thousandths +1;
if (thousandths == 10){
thousandths = 0;
hundredths = hundredths +1;
}
if (hundredths == 10){
hundredths = 0;
tenths = tenths +1;
}
if (tenths == 10){
tenths = 0;
ones_seconds = ones_seconds +1;
}
if (ones_seconds == 10){
ones_seconds = 0;
tens_seconds = tens_seconds +1;
}
if (tens_seconds == 6){
tens_seconds = 0;
ones_minutes = ones_minutes +1;
}
digitalWrite(latchpin, LOW); // send the digits down to the shift registers!
shiftOut(datapin, clockpin, MSBFIRST, segdisp[tens_seconds]);
shiftOut(datapin, clockpin, MSBFIRST, segdisp[ones_seconds]);
shiftOut(datapin, clockpin, MSBFIRST, segdisp[tenths]);
shiftOut(datapin, clockpin, MSBFIRST, segdisp[hundredths]);
shiftOut(datapin, clockpin, MSBFIRST, segdisp[thousandths]);
digitalWrite(latchpin, HIGH);
}
}
}