Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

Digital Clock with Arduino

The importance and utility of a digital clock is undeniable. It provides accurate timekeeping, eliminates the need for manual adjustment, and can be easily customized to display additional information such as date, temperature, or humidity. In this article, we will explore how to create a digital clock using an Arduino board.

Project: The project involves creating a digital clock using an Arduino board and an LCD display. The clock will display the time in hours, minutes, and seconds, and will update in real-time. Additionally, the clock will have the ability to adjust the time manually using buttons connected to the Arduino.

List of components:

  • Arduino Uno board x1
  • LCD display (16x2) x1
  • Breadboard x1
  • Jumper wires x10
  • Push buttons x3
  • 10k ohm resistors x3

Examples:

  1. Displaying the current time:
    
    #include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() { lcd.begin(16, 2); lcd.print("Digital Clock"); }

void loop() { lcd.setCursor(0, 1); lcd.print("Time: " + String(hour()) + ":" + String(minute()) + ":" + String(second())); delay(1000); }

This code initializes the LCD display and continuously updates it with the current time in hours, minutes, and seconds.

2. Manual time adjustment:
```cpp
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int buttonPin = 6;
int buttonState = 0;

void setup() {
  lcd.begin(16, 2);
  lcd.print("Digital Clock");
  pinMode(buttonPin, INPUT);
}

void loop() {
  buttonState = digitalRead(buttonPin);

  if (buttonState == HIGH) {
    adjustTime();
  }

  lcd.setCursor(0, 1);
  lcd.print("Time: " + String(hour()) + ":" + String(minute()) + ":" + String(second()));
  delay(1000);
}

void adjustTime() {
  lcd.clear();
  lcd.print("Adjusting Time");

  // Code to adjust time
}

This code adds a button to the circuit and allows the user to manually adjust the time displayed on the LCD.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.