Introduction: DIY Clock With Arduino Nano and PCB

Hey there, DIY enthusiast! If you're itching for a project that's both fun and functional, we've got just the thing for you – your very own Arduino Nano clock! Imagine, a personalized timepiece that not only keeps you on schedule but also adds a sprinkle of your unique style to any space.

In this friendly, step-by-step guide, we'll be taking you through the process of creating a snazzy digital clock using an Arduino Nano, a snazzy custom-designed PCB, push buttons, resistors, and a 7-segment 4-digit display. Whether you're a seasoned tech wizard or a total newbie, this project promises a hands-on adventure in electronics – and the best part? You get to end it with a clock that's uniquely yours!

So, grab your soldering iron, roll up your sleeves, and let's dive into the world of circuitry, coding, and creativity. By the end of this journey, you won't just have a cool timekeeping gadget; you'll have a tale to tell and a clock that reflects your personality. Let's turn those DIY dreams into reality – time to make your own time! Ready, set, DIY!

Supplies

Please note that the following list of supplies is for reference only and is not sponsored unless mentioned otherwise. You can find these components at various online retailers, electronics supply websites, or local electronics stores:


  1. Arduino Nano
  2. 7-Segment 4-Digit Display 0.55"
  3. Push Buttons (x3)
  4. Resistors 220 Ohm
  5. Soldering Iron and Solder Wire
  6. Custom-Designed PCB

Remember to verify the specifications and compatibility of these components with your project, read reviews, and check ratings to ensure you're getting the right quality components for your needs.

Step 1: Building a Breadboard Prototype

Before diving into soldering and assembling your components onto the custom-designed PCB, it's a smart move to create a breadboard prototype. This allows you to test the functionality of your circuit and ensure that everything is working smoothly before making a more permanent commitment.


Arrange Components on Breadboard:

  • Place the Arduino Nano, 7-segment display, push buttons, and resistors on the breadboard according to the circuit diagram.

Wiring Connections:

  • Use jump wires to connect the components according to your schematic. Pay attention to the orientation of the components and ensure correct connections.

Test the Circuit:

  • Power up the Arduino Nano using the USB cable and connect it to your computer. Upload a simple test code to check if the display lights up, and buttons respond as expected.

Debugging:

  • Troubleshoot any issues with the circuit. Check for loose connections, incorrect wiring, or component malfunctions.

Adjust Code if Necessary:

  • If any issues arise, modify your Arduino code accordingly. Debugging at this stage is easier and prevents potential problems later.

Verify Timekeeping Functions:

  • Test the clock's basic functions such as setting the time and cycling through modes using the push buttons.

Document and Take Notes:

  • Record your successful connections, any issues encountered, and changes made during this breadboarding phase. This documentation will be handy when you move on to the final assembly.

By building a breadboard prototype, you're giving yourself the chance to catch and address any issues early on. Once you're satisfied with the prototype's performance, you're ready to move on to the exciting phase of soldering and creating your permanent clock circuit!

Step 2: Code

I am sharing some basic code with you. You can make the Misc. Button (A2) do anything you like. I have it adjust the brightness in this example, but other options could be resetting the clock, starting a timer, changing the time format etc. Also, on the PCB you can see the connections on the lower left corner for the display.


#include <SevSeg.h>


SevSeg sevseg;


byte numDigits = 4;
byte digitPins[] = {4,3,2,5}; // Connect these pins to the digit pins of your 5641AS display
byte segmentPins[] = {12,13,7,9,10,11,6,8}; // Connect these pins to the segment pins of your 5641AS display


// Define the pins for your buttons
const int hourButtonPin = A1; // Change these pins to match your setup
const int minuteButtonPin = A0;
const int brightnessButtonPin = A2;  // Button for cycling brightness


int currentHour = 0;
int currentMinute = 0;
bool segmentDOn = false; // Flag to control segment D blinking


int brightnessLevels[] = {0, 30, 60, 90, 100}; // Adjust brightness levels as needed
int currentBrightnessLevel = 2; // Initial brightness level


unsigned long previousMillis = 0;
const long interval = 1000; // 1000 milliseconds = 1 second
const long minuteInterval = 60000; // 60000 milliseconds = 60 seconds
const long brightnessChangeInterval = 500; // Adjust the interval for brightness change


void setup() {
  bool leadingZeros = true;
  sevseg.begin(COMMON_CATHODE, numDigits, digitPins, segmentPins, leadingZeros);


  // Set button pins as INPUT_PULLUP
  pinMode(hourButtonPin, INPUT_PULLUP);
  pinMode(minuteButtonPin, INPUT_PULLUP);
  pinMode(brightnessButtonPin, INPUT_PULLUP);


  // Initialize Serial communication
  Serial.begin(9600);
}


void loop() {
  unsigned long currentMillis = millis();


  // Read the button states and update the time
  if (digitalRead(hourButtonPin) == LOW) {
    currentHour = (currentHour + 1) % 24;
    delay(250); // Debounce the button
  }
  if (digitalRead(minuteButtonPin) == LOW) {
    currentMinute = (currentMinute + 1) % 60;
    delay(250); // Debounce the button
  }


  // Check if a minute has passed
  if (currentMillis - previousMillis >= minuteInterval) {
    // Increment the minute when a minute has passed
    currentMinute = (currentMinute + 1) % 60;
    previousMillis = currentMillis;


    // Check if 60 minutes have passed to increment the hour
    if (currentMinute == 0) {
      currentHour = (currentHour + 1) % 24;
    }
  }




  sevseg.setNumber(currentHour * 100 + currentMinute, 2); // Display segment D (1) off on the first digit

// Cycle through brightness levels if the button is pressed
  if (digitalRead(brightnessButtonPin) == LOW && currentMillis - previousMillis >= brightnessChangeInterval) {
    currentBrightnessLevel = (currentBrightnessLevel + 1) % (sizeof(brightnessLevels) / sizeof(brightnessLevels[0]));
    sevseg.setBrightness(brightnessLevels[currentBrightnessLevel]);
    previousMillis = currentMillis;
    delay(250); // Debounce the button
  }


  sevseg.refreshDisplay();
}

Step 3: Fabricate PCB

You can use my design as is, or you can make any changes you like. Try adding shapes and logos, or changing the size and shape of the board. I suggest moving the Nano a bit lower as it is very close to the Minutes Button.


This project came to fruition thanks to the invaluable assistance and support from NextPCB, a trusted manufacturer specializing in multilayer PCBs. NextPCB boasts over 15 years of experience in the global PCB and assembly industry, making it a reliable partner for projects like these.

I accepted this partnership because I am familiar with their products, and I have consistently been satisfied with the quality and service they provide.

You can explore their high-quality PCBs, starting at just $1.9, and multilayer options beginning at $6.9 at the following link: NextPCB - Get a PCB Quote

As a bonus, enjoy free PCB assembly for the first 5 boards through this link: NextPCB - Get a PCB Assembly Quote

Additionally, NextPCB offers a DFM (Design for Manufacturability) free online PCB Gerber viewer to help streamline your PCB design process: NextPCB - Free Online Gerber Viewer

Their expertise and resources can undoubtedly facilitate your projects. Happy creating!

Step 4: Assmble PCB

Once the PCBs arrive, and you have all of the required components for the assembly, power up your soldering iron and start putting everything together. The PCB is annotated so everything should be straightforward. 

Step 5: Conclusion

I enjoyed designing and building this custom-made clock. The functionality is simple but I love the exposed style. Try different colors for the PCB if you wish.


Thanks for reading,

Yiannis