ATTINY+ RS3231 Watch Project Help

Hello everyone,
I am a mechanical guy looking to expand my electronics skills. I would like to make a simple digital watch mainly for academic fun. Right now I am running into endless issues due to my inexperience. My plan currently is to use an ATTINY 84 linked to a DS3231 TXCO to keep time with lower power consumption. The display will be a 7-Segment LED display. I am going for something close to this: 555Dreams: Creating a DIP ATtiny85 Watch with the DS3231 I want the time to show when you press a small button as a series of digit flashed sequentially. I.E. "0...9...4...5" on for one second, off half a second. My main problem is that I have found a method to brute force the problem that works. However I know there has to be a better way, but I don't have the knowledge to figure it out on my own. I have the code working here on Wokwi Simulator using an Arduino Uno and a DS1307 RTC Module: sketch.ino - Wokwi Arduino Simulator In the code I have only coded one single minute of time, where it reads the RTC time as a variable and performs some basic logic to give outputs to the necessary segments. I would need to write out a set of pin logic commands for every single minute of the day for this setup to work. The code in the simulation only works when you press the button within the 4:01pm minute, it work exactly as I want though. I would love suggestions for streamlining with special emphasis on reducing required memory in order to fit this onto smaller ATTINY platforms later.

Your post was MOVED to its current location as it is more suitable.

Consider using a 2-dimensional array to hold the details for each digit. Then simply reference the array for determining which segments are required when displaying.

The following uses the same pinouts as your sketch... should work in the simulator.

int8_t pinSegA = 6;
int8_t pinSegB = 7;
int8_t pinSegC = 8;
int8_t pinSegD = 2;
int8_t pinSegE = 3;
int8_t pinSegF = 5;
int8_t pinSegG = 4;


// Segment                 a  b  c  d  e  f  g     // Digit
//
boolean digits [10] [7] = {1, 1, 1, 1, 1, 1, 0,    // 0
                           0, 1, 1, 0, 0, 0, 0,    // 1
                           1, 1, 0, 1, 1, 0, 1,    // 2
                           1, 1, 1, 1, 0, 0, 1,    // 3
                           0, 1, 1, 0, 0, 1, 1,    // 4
                           1, 0, 1, 1, 0, 1, 1,    // 5
                           0, 0, 1, 1, 1, 1, 1,    // 6
                           1, 1, 1, 0, 0, 0, 0,    // 7
                           1, 1, 1, 1, 1, 1, 1,    // 8
                           1, 1, 1, 0, 0, 1, 1, }; // 9



void setup ()
{
  pinMode (pinSegA, OUTPUT);
  pinMode (pinSegB, OUTPUT);
  pinMode (pinSegC, OUTPUT);
  pinMode (pinSegD, OUTPUT);
  pinMode (pinSegE, OUTPUT);
  pinMode (pinSegF, OUTPUT);
  pinMode (pinSegG, OUTPUT);
}



void loop ()
{
  for (uint8_t x = 0; x <10; x++)
  {
    displayDigit(x);
  }
}

void displayDigit(uint8_t digit)
{
  // Display the digit
  digitalWrite(pinSegA, digits[digit][0]);
  digitalWrite(pinSegB, digits[digit][1]);
  digitalWrite(pinSegC, digits[digit][2]);
  digitalWrite(pinSegD, digits[digit][3]);
  digitalWrite(pinSegE, digits[digit][4]);
  digitalWrite(pinSegF, digits[digit][5]);
  digitalWrite(pinSegG, digits[digit][6]);

  delay(1000);

  // Clear the display
  digitalWrite(pinSegA, LOW);
  digitalWrite(pinSegB, LOW);
  digitalWrite(pinSegC, LOW);
  digitalWrite(pinSegD, LOW);
  digitalWrite(pinSegE, LOW);
  digitalWrite(pinSegF, LOW);
  digitalWrite(pinSegG, LOW);

  delay(300);
}

1 Like

So if I understand correctly, this will allow me to define a grouping of LED outputs as a single character so that I can tell it to display the number by only having to modify one output phrase rather than all 7 each time?

Yes, essentially - you will just need to call displayDigit(x) with the digit you want to display.

For your clock you would just call it 4 times to display the HHMM digits.

Did you try running in the simulator?

Don't forget, the DS3231 communicates with I2C but the tiny84 does not have I2C but USI (Universal Serial Interface), it will work but is not straight forward, takes some extra programming. Check page 122 in the datasheet. Search "I2C with USI".
https://ww1.microchip.com/downloads/en/DeviceDoc/ATtiny24A-44A-84A-DataSheet-DS40002269A.pdf

Years ago, I built a clock using a tiny85 and watch-crystal as the precision 1 second source.

ATtiny25/45/85 Blink 32KHz
Version: 1.0
Author: Alex from Inside Gadgets (http://www.insidegadgets.com)
Created: 2/010/2011

Download from link in his YouTube:
https://www.youtube.com/watch?v=ZAiz_OPkx-M

1 Like

When I run your code without modification it cycles through all 10 digits, however there are some weird number errors where segments turn on that should be off or on when they shouldn't be. It looks like your Boolean matrix calls out all of the correct segments so I am not sure what that's all about? I still need to work out how to integrate your code suggestions into the logic I am working on for display but I really appreciate your help so far!

Yeah I think that's a bridge will have to cross eventually but for now I am focusing on the UNO because I am still learning the coding basics.

Seem to run fine when I tried in the simulator. sketch.ino - Wokwi Arduino Simulator

If you are testing on proper hardware then check the pin assignments to the segments.

okay great news, I was able to integrate you code into mine and it functions partially now. I still only coded up one minute of the day but if you change the numbers around in the if statements then you can see that it works with the current time. The current time code is for 9:53. My next step is to parse out the numbers using %x functions so that I only have to code 40 unique logic sets rather than 84 for all of the time combinations.

#include "RTClib.h"

RTC_DS1307 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
const int buttonPin = 9;  //User input button declaration
int buttonState = 0;  //
int8_t pinSegA = 6;
int8_t pinSegB = 7;
int8_t pinSegC = 8;
int8_t pinSegD = 2;
int8_t pinSegE = 3;
int8_t pinSegF = 5;
int8_t pinSegG = 4;

// Segment                 a  b  c  d  e  f  g     // Digit
//
boolean digits [10] [7] = {1, 1, 1, 1, 1, 1, 0,    // 0
                           0, 1, 1, 0, 0, 0, 0,    // 1
                           1, 1, 0, 1, 1, 0, 1,    // 2
                           1, 1, 1, 1, 0, 0, 1,    // 3
                           0, 1, 1, 0, 0, 1, 1,    // 4
                           1, 0, 1, 1, 0, 1, 1,    // 5
                           0, 0, 1, 1, 1, 1, 1,    // 6
                           1, 1, 1, 0, 0, 0, 0,    // 7
                           1, 1, 1, 1, 1, 1, 1,    // 8
                           1, 1, 1, 0, 0, 1, 1, }; // 9

void setup () {
  Serial.begin(115200);
 
  if (! rtc.begin()) {2;
    Serial.println("Couldn't find RTC");
    Serial.flush();
    abort();
  }

  pinMode (pinSegA, OUTPUT);
  pinMode (pinSegB, OUTPUT);
  pinMode (pinSegC, OUTPUT);
  pinMode (pinSegD, OUTPUT);
  pinMode (pinSegE, OUTPUT);
  pinMode (pinSegF, OUTPUT);
  pinMode (pinSegG, OUTPUT);
  pinMode(buttonPin, INPUT);
}
void displayDigit(uint8_t digit)
{
  // Display the digit
  digitalWrite(pinSegA, digits[digit][0]);
  digitalWrite(pinSegB, digits[digit][1]);
  digitalWrite(pinSegC, digits[digit][2]);
  digitalWrite(pinSegD, digits[digit][3]);
  digitalWrite(pinSegE, digits[digit][4]);
  digitalWrite(pinSegF, digits[digit][5]);
  digitalWrite(pinSegG, digits[digit][6]);

  delay(1200);

  // Clear the display
  digitalWrite(pinSegA, LOW);
  digitalWrite(pinSegB, LOW);
  digitalWrite(pinSegC, LOW);
  digitalWrite(pinSegD, LOW);
  digitalWrite(pinSegE, LOW);
  digitalWrite(pinSegF, LOW);
  digitalWrite(pinSegG, LOW);

}


void loop () {


DateTime now = rtc.now();

 
  Serial.print("Current time: ");
  Serial.print(now.hour());
  Serial.print(':');
  Serial.print(now.minute());
  //Serial.print(':');
  //Serial.print(now.second());
  Serial.println();
 
 buttonState = digitalRead(buttonPin);

if (buttonState == HIGH) {

  if (now.hour() == 21) {
    displayDigit(0);
    delay(300);
    displayDigit(9);
        delay(300);
  }
  if (now.minute() == 53) {
    displayDigit(5);
        delay(300);
    displayDigit(3);
        delay(300);
  }
}
    
 else {

digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
}
}

You don't need to hard code each digit... just extract the digits from the time (HHMM) and pass to the display routine.

For example...

void setup()
{
  Serial.begin(9600);
  delay(500);
  
  int minutes = 53;

  int tens = minutes / 10;
  int ones = minutes % 10;

  Serial.print ("Minutes: ");
  Serial.println (minutes);
  Serial.print ("Tens: ");
  Serial.println (tens);
  Serial.print ("One : ");
  Serial.println (ones);
  
  
}

void loop ()
{
  
}

16:07:54.575 -> Minutes: 53
16:07:54.575 -> Tens: 5
16:07:54.575 -> One : 3

You also don't need the delays... they are already happening in the display routine.

And you don't need to clear the display (else statement)... that also already happens in the display routine.

Your new code should be much more compact ...

The delays are included because I want to control the length of time on and off between numbers, not just a regular 500ms interval. I have also left the clear display stuff because when I remove it the numbers get squirrely while transitioning, might just be an issue with the simulator though.

Also I am assuming that I should replace "53" in the code above with "now.minutes()" correct, and then I don't need any "if" statements I would just write "displayDigit(ones)"

Correct.

You should add an extra parameter to the display routine... that controls the delay time.

void displayDigit(uint8_t digit, uint16_t delayTime)

Then in the routine

delay(delayTime);

I have also left the clear display stuff because when I remove it the numbers get squirrely while transitioning, might just be an issue with the simulator though.

This is already being done in the display routine.

What is the correct formatting for converting the hours, for all of the math I have mastered in school this dumb little function is elluding me tonight. I have this but it is showing hours incorrectly:

int minutes = now.minute();
  int tens = minutes / 10;
  int ones = minutes % 10;
  int hours = now.hour();
  int tenss = hours / 12;
  int oness = hours - 10;

 buttonState = digitalRead(buttonPin);

if (buttonState == HIGH) {


    displayDigit(tenss);
    delay(250);
    displayDigit(oness);
        delay(250);
  

    displayDigit(tens);
        delay(250);
    displayDigit(ones);
        delay(250);
  
}

Should be...

int tenss = hours / 10;

You are just trying to get the tens part of the hours... 0, 1, or 2.

If you don't want to use a 24 hour clock then subtract 12 if hours > 12 before you start.

Got it! This is working perfectly now! Thank you so much for your help on this, I can move onto the actually putting the circuit together in hardware.

#include "RTClib.h"

RTC_DS1307 rtc;

const int buttonPin = 9;  
int buttonState = 0; 
int8_t pinSegA = 6;
int8_t pinSegB = 7;
int8_t pinSegC = 8;
int8_t pinSegD = 2;
int8_t pinSegE = 3;
int8_t pinSegF = 5;
int8_t pinSegG = 4;

// Segment                 a  b  c  d  e  f  g     // Digit
boolean digits [10] [7] = {1, 1, 1, 1, 1, 1, 0,    // 0
                           0, 1, 1, 0, 0, 0, 0,    // 1
                           1, 1, 0, 1, 1, 0, 1,    // 2
                           1, 1, 1, 1, 0, 0, 1,    // 3
                           0, 1, 1, 0, 0, 1, 1,    // 4
                           1, 0, 1, 1, 0, 1, 1,    // 5
                           1, 0, 1, 1, 1, 1, 1,    // 6
                           1, 1, 1, 0, 0, 0, 0,    // 7
                           1, 1, 1, 1, 1, 1, 1,    // 8
                           1, 1, 1, 0, 0, 1, 1, }; // 9

void setup () {
 
  if (! rtc.begin()) {2;
    abort();
  }

  pinMode (pinSegA, OUTPUT);
  pinMode (pinSegB, OUTPUT);
  pinMode (pinSegC, OUTPUT);
  pinMode (pinSegD, OUTPUT);
  pinMode (pinSegE, OUTPUT);
  pinMode (pinSegF, OUTPUT);
  pinMode (pinSegG, OUTPUT);
  pinMode(buttonPin, INPUT);
}
void displayDigit(uint8_t digit)
{
  digitalWrite(pinSegA, digits[digit][0]);
  digitalWrite(pinSegB, digits[digit][1]);
  digitalWrite(pinSegC, digits[digit][2]);
  digitalWrite(pinSegD, digits[digit][3]);
  digitalWrite(pinSegE, digits[digit][4]);
  digitalWrite(pinSegF, digits[digit][5]);
  digitalWrite(pinSegG, digits[digit][6]);
  delay(1100);

  digitalWrite(pinSegA, LOW);
  digitalWrite(pinSegB, LOW);
  digitalWrite(pinSegC, LOW);
  digitalWrite(pinSegD, LOW);
  digitalWrite(pinSegE, LOW);
  digitalWrite(pinSegF, LOW);
  digitalWrite(pinSegG, LOW);

}

void loop () {

DateTime now = rtc.now();
 
  int minutes = now.minute();
  int tens = minutes / 10;
  int ones = minutes % 10;
  int hours = now.hour() - 12;
  int tenss = (hours / 10);
  int oness = (hours % 10);

 buttonState = digitalRead(buttonPin);

if (buttonState == HIGH) {

    displayDigit(tenss);
        delay(250);
    displayDigit(oness);
        delay(250);
    displayDigit(tens);
        delay(250);
    displayDigit(ones);
        delay(250);
  
}
}

Cool. Feel free to mark one of the posts as the Solution as you see fit...

1 Like

Hey everyone I am back with this wristwatch project I am working on. So far the code works by flashing each digit of the current time in 12 hour format with AM and PM, it also removes the superfluous zero from AM time. Eventually I would like to run this on an ATtiny85 so I am trying to get the code to run with fewer lines but I am a newbie. My current issues that I would like to add onto the matrix which defines the pixel logic three things for now:
the letter A, P, and a blank array (all zeros) for clearing the display.

boolean digits [13] [7] = {1, 1, 1, 1, 1, 1, 0,    // 0
                           0, 1, 1, 0, 0, 0, 0,    // 1
                           1, 1, 0, 1, 1, 0, 1,    // 2
                           1, 1, 1, 1, 0, 0, 1,    // 3
                           0, 1, 1, 0, 0, 1, 1,    // 4
                           1, 0, 1, 1, 0, 1, 1,    // 5
                           1, 0, 1, 1, 1, 1, 1,    // 6
                           1, 1, 1, 0, 0, 0, 0,    // 7
                           1, 1, 1, 1, 1, 1, 1,    // 8
                           1, 1, 1, 0, 0, 1, 1,    // 9
                           1, 1, 1, 0, 1, 1, 1,    // A
                           1, 1, 0, 0, 1, 1, 1,    // P
                           0, 0, 0, 0, 0, 0, 0, }; // null

The I tried call out the three rows at the bottom the same way as numbers:

displayDigit(A);
displayDigit(P);
displayDigit(null);

I know that this is incorrect use of these functions, and it obviously did not work, but I am not sure how to implement what I want. I think it has to do with 'string()' but I don't know how.

Here is the complete working code for my Wokwi simulation:

/*
Written by Austin Fox for a simple low power digital wristwatch
to operate simply press the pushbutton and the current 12-hour time will flash sequentially

for wiring in Wokwi.com paste the following into diagram.json:

{
  "version": 1,
  "author": "Austin Fox",
  "editor": "wokwi",
  "parts": [
    { "type": "wokwi-arduino-uno", "id": "uno", "top": 0, "left": 0, "attrs": {} },
    {
      "type": "wokwi-7segment",
      "id": "sevseg1",
      "top": 61.86,
      "left": 501.89,
      "attrs": { "color": "white", "common": "cathode" }
    },
    {
      "type": "wokwi-pushbutton",
      "id": "btn1",
      "top": 78.35,
      "left": 755.51,
      "attrs": { "color": "BL" }
    },
    { "type": "wokwi-resistor", "id": "r1", "top": 11.34, "left": 572.35, "attrs": {} },
    { "type": "wokwi-resistor", "id": "r2", "top": 36.61, "left": 571.72, "attrs": {} },
    { "type": "wokwi-resistor", "id": "r3", "top": 35.74, "left": 415.68, "attrs": {} },
    { "type": "wokwi-resistor", "id": "r4", "top": 12.67, "left": 416.82, "attrs": {} },
    { "type": "wokwi-resistor", "id": "r5", "top": 154.2, "left": 424.05, "attrs": {} },
    { "type": "wokwi-resistor", "id": "r6", "top": 178.06, "left": 425.89, "attrs": {} },
    { "type": "wokwi-resistor", "id": "r7", "top": 157.78, "left": 578.53, "attrs": {} },
    { "type": "wokwi-resistor", "id": "r8", "top": 183.15, "left": 580.24, "attrs": {} },
    { "type": "wokwi-ds1307", "id": "rtc1", "top": 289.42, "left": 275.99, "attrs": {} }
  ],
  "connections": [
    [ "r5:2", "sevseg1:E", "green", [ "v-0.34", "h24.81" ] ],
    [ "sevseg1:D", "r6:2", "green", [ "v0" ] ],
    [ "sevseg1:C", "r7:1", "green", [ "v0" ] ],
    [ "sevseg1:G", "r3:2", "green", [ "v0" ] ],
    [ "sevseg1:F", "r4:2", "green", [ "v0" ] ],
    [ "sevseg1:A", "r1:1", "green", [ "v0" ] ],
    [ "sevseg1:B", "r2:1", "green", [ "v0" ] ],
    [ "uno:GND.2", "r8:1", "black", [ "v47.38", "h366.87", "v-59.81" ] ],
    [ "uno:5V", "rtc1:5V", "red", [ "v0" ] ],
    [ "uno:GND.2", "rtc1:GND", "black", [ "v0" ] ],
    [ "rtc1:SDA", "uno:A4", "green", [ "h0" ] ],
    [ "rtc1:SCL", "uno:A5", "green", [ "h0" ] ],
    [ "r8:2", "btn1:2.r", "green", [ "v-0.02", "h209.95", "v-77.97" ] ],
    [ "uno:5V", "btn1:1.r", "red", [ "v69.31", "h714.16", "v-174.54" ] ],
    [ "r6:1", "uno:2", "green", [ "v0.04", "h-135.09", "v-203.33", "h-77.93" ] ],
    [ "r5:1", "uno:3", "green", [ "v-0.29", "h-109.06", "v-201.54", "h-85.09" ] ],
    [ "r3:1", "uno:4", "green", [ "v-0.06", "h-75.61", "v-106.59", "h-130.78" ] ],
    [ "r4:1", "uno:5", "green", [ "v-0.28", "h-52.57", "v-105.7", "h-175.56" ] ],
    [ "r1:2", "uno:6", "green", [ "v-0.2", "h32.78", "v-128.07", "h-470.29" ] ],
    [ "r2:2", "uno:7", "green", [ "v0.14", "h58", "v-176.23", "h-495.91" ] ],
    [ "r7:2", "uno:8", "green", [ "v-0.51", "h76.34", "v-318.39", "h-575.35" ] ],
    [ "btn1:2.l", "uno:9", "green", [ "h-18.57", "v-291.54", "h-564.07" ] ],
    [ "uno:GND.3", "sevseg1:COM.1", "black", [ "v24.72", "h310.55" ] ]
  ]
}

  A  
F   B
  G
E   C
  D

*/

#include "RTClib.h"
RTC_DS1307 rtc;
const int buttonPin = 9;  //user input
int buttonState = 0;      //remove uncertainty
int8_t pinSegA = 6;       //7-segment display input pins
int8_t pinSegB = 7;       //7-segment display input pins
int8_t pinSegC = 8;       //7-segment display input pins
int8_t pinSegD = 2;       //7-segment display input pins
int8_t pinSegE = 3;       //7-segment display input pins
int8_t pinSegF = 5;       //7-segment display input pins
int8_t pinSegG = 4;       //7-segment display input pins
// Segment                 a  b  c  d  e  f  g     // Digit
boolean digits [10] [7] = {1, 1, 1, 1, 1, 1, 0,    // 0
                           0, 1, 1, 0, 0, 0, 0,    // 1
                           1, 1, 0, 1, 1, 0, 1,    // 2
                           1, 1, 1, 1, 0, 0, 1,    // 3
                           0, 1, 1, 0, 0, 1, 1,    // 4
                           1, 0, 1, 1, 0, 1, 1,    // 5
                           1, 0, 1, 1, 1, 1, 1,    // 6
                           1, 1, 1, 0, 0, 0, 0,    // 7
                           1, 1, 1, 1, 1, 1, 1,    // 8
                           1, 1, 1, 0, 0, 1, 1, }; // 9
void setup () {
  if (! rtc.begin()) {2;   //RTC check
    abort();
  }
  pinMode (pinSegA, OUTPUT);  //IO definitions
  pinMode (pinSegB, OUTPUT); 
  pinMode (pinSegC, OUTPUT);  
  pinMode (pinSegD, OUTPUT); 
  pinMode (pinSegE, OUTPUT);  
  pinMode (pinSegF, OUTPUT);  
  pinMode (pinSegG, OUTPUT); 
  pinMode(buttonPin, INPUT);  
}
void displayDigit(uint8_t digit)
{
  digitalWrite(pinSegA, digits[digit][0]);  //assigns numerals to the matrix
  digitalWrite(pinSegB, digits[digit][1]);
  digitalWrite(pinSegC, digits[digit][2]);
  digitalWrite(pinSegD, digits[digit][3]);
  digitalWrite(pinSegE, digits[digit][4]);
  digitalWrite(pinSegF, digits[digit][5]);
  digitalWrite(pinSegG, digits[digit][6]);
  delay(1100);
  digitalWrite(pinSegA, LOW); //clears any persistant lit segments (needed for code to work)
  digitalWrite(pinSegB, LOW);
  digitalWrite(pinSegC, LOW);
  digitalWrite(pinSegD, LOW);
  digitalWrite(pinSegE, LOW);
  digitalWrite(pinSegF, LOW);
  digitalWrite(pinSegG, LOW);
}
void loop () {
DateTime now = rtc.now();   //defines time in library
  int minutes = now.minute();   //defines minutes
  int tens = minutes / 10;    //parsing tens and ones place from minutes
  int ones = minutes % 10;
  int hours = now.hour();   //defines hours
  int tenss = hours / 10;   //parsing tens and ones place from hours
  int oness = hours % 10;
  int hoursss = hours - 12;   //variable for 12 hr time
buttonState = digitalRead(buttonPin);   //checks button high or low
if (buttonState == HIGH)     
{
  if (hours >= 12)    //12 hour time logic
  {
  displayDigit(hoursss);
  } 
  else if (hours < 12) 
  {
    if (tenss > 0) {      //removes zero from tens place so AM time only shows 3 digits
     displayDigit(tenss);
     delay(250);
    } 
    displayDigit(oness);
  }
        delay(250);
    digitalWrite(pinSegG, HIGH);    //shows hyphen to replace normal colon
        delay(500);
    digitalWrite(pinSegG, LOW);     //shows hyphen to replace normal colon
        delay(250);
    displayDigit(tens);
        delay(250);
    displayDigit(ones);
        delay(250);
    if (hours >= 12)                //diplays P for PM
    {
      digitalWrite(pinSegA, HIGH);
      digitalWrite(pinSegB, HIGH);
      digitalWrite(pinSegE, HIGH);
      digitalWrite(pinSegF, HIGH);
      digitalWrite(pinSegG, HIGH);  
    } else if (hours < 12) {        //displays A for AM
      digitalWrite(pinSegA, HIGH);
      digitalWrite(pinSegB, HIGH);
      digitalWrite(pinSegC, HIGH);
      digitalWrite(pinSegE, HIGH);
      digitalWrite(pinSegF, HIGH);
      digitalWrite(pinSegG, HIGH);
    }
    delay(1100);
    digitalWrite(pinSegA, LOW);
    digitalWrite(pinSegB, LOW);
    digitalWrite(pinSegC, LOW);
    digitalWrite(pinSegD, LOW);
    digitalWrite(pinSegE, LOW);
    digitalWrite(pinSegF, LOW);
    digitalWrite(pinSegG, LOW); 
}
}