8x7 Segment LED Anzeige / Sketch verändern

Hi zusammen,

Ich bin absoluter Neuling in Sachen Arduino :slight_smile: und stehe vor einem für mich anscheinend unlösbarem Problem :smiley:

Ich habe einen Countdown-Timer Sketch im Internet gefunden und wollte ihn etwas umändern.

Der Timer sollte nach Möglichkeit nur auf den Segmenten 7,6,5,4,3,2 angezeigt werden ( 8 und 1 blank )
Weiterhin habe ich versucht bei dem 6. und 4, Segment den Punkt in der Ecke zu aktivieren, seit etlichen Stunden erfolglos :smiley:
Der Countdown wird in HHMMSS angezeigt.

Wäre super wenn da mal wer raufgucken kann und mir dabei helfen könnte sofern dies überhaupt möglich ist :slight_smile:

Vielen Dank schonmal im Voraus :slight_smile:

Gruß der w1ck3d :stuck_out_tongue:

Und jetzt mal der Code

//Countdown Timer Sketch

#define LATCH  12  //pin 12 connect to RCK
#define CLOCK  11  //pin 11 connect to SCK
#define DATA   10  //pin 10 connect to DIO
#define BUZZ    3  //pin 3  connect to Buzzer
#define BUTTON  5  //pin 5 connect to Button
#define LEFT   0  // define the value for left justify
#define RIGHT  1  // define the value for right justify

int buzztrig = 9; //Trigger counter for Buzzer
String mystring; //Save Counter Value to a String
unsigned long value = 2000000; // Countdown value: HHMMSSS

// 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.
//logic low will activate the particular segment
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(1); 
}
}
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(1); 
}
}
else 
{
display8x7segment(DATA, CLOCK, LATCH, anode[7-d], cathode[decimal[e-1]]);
d ++;
delay(1); 
}     
}
} 
}


void setup() {
pinMode(LATCH, OUTPUT);
pinMode(CLOCK, OUTPUT);
pinMode(DATA, OUTPUT);
pinMode(BUZZ, OUTPUT);
pinMode(BUTTON, INPUT_PULLUP);
digitalWrite(LATCH, HIGH); //Wake Up Display 
digitalWrite(BUZZ, LOW);  //Buzzer Off
digitalWrite(BUTTON, HIGH); // Button Low  
delay(1000);  //delay for 1 second
}

void loop(){ 
//Wait for button press to start Countdown
while(digitalRead(BUTTON) == HIGH){
displayNumber8x7segment(RIGHT, value);  //display the Countdown Start value
}
for (value; value != -1; value --)
{        
for(byte i = 9; i > 0; i --) // Adjust i=x to speed up or slow time
{
String mystring = String(value); //Transform Counter Int to String
//Do time Offset 
for (int z = 0; z < 5; z++){
if ( mystring.substring(z) == "99999" ) {
value = (value - 40000);
}        
if ( mystring.substring(z) == "999" ) {
value = (value - 400);
}
}
displayNumber8x7segment(RIGHT, value);  //display the value in right justify format      
} 
// Countdown is Finished? Sound Alarm
if (value == 0) {
for(byte k = 0; k < 11; k++)
{
for (int j = 0; j <80; j++) // Buzzer frequency sound 1
{
digitalWrite (BUZZ, HIGH) ;// Buzzer On
delay (1) ;// Delay 1ms
digitalWrite (BUZZ, LOW) ;// Buzzer Off
delay (1) ;// delay 1ms
}
for (int j = 0; j <100; j++) // Buzzer frequency sound 2
{
digitalWrite (BUZZ, HIGH) ;// Buzzer On
delay (2) ;// delay 2ms
digitalWrite (BUZZ, LOW) ;// Buzzer Off
delay (2) ;// delay 2ms
}
display8x7segment(DATA, CLOCK, LATCH, 0xff, cathode[0]);  //activate all digit  // Put ALL zeros
delay(300);
display8x7segment(DATA, CLOCK, LATCH, 0xff, cathode[11]); // Blank Display
delay(300);
}  
}
//Countdown Tick sound
if (buzztrig == 0){
for (int i = 0; i <5; i++) // Buzzer frequency sound
{
digitalWrite (BUZZ, HIGH) ;// Buzzer On
delay (2) ;// Delay 2ms
digitalWrite (BUZZ, LOW) ;// Buzzer Off
delay (1) ;// delay ms
} 
buzztrig = 9; //  Trigger for countdown sound
}
else {
buzztrig = buzztrig - 1;
}
}  
}