Project Report Aa
Project Report Aa
PROJECT REPORT
Submitted
by
AADIL MUHAMMED
Reg No : MBC22EC001
Components Required -
1. Arduino UNO-1
2. OLED Display(128X64 I2C) -1
3. Push button -2
4. Breadboard -1
5. Jumber Wires
6. DC Power Supply
Circuit Diagram
2
CONTENTS
CHAPTER 1
• Introduction
CHAPTER 2
• Proposed Work
• Design and Modelling
CHAPTER 3
• Results
CHAPTER 4
• Conclusion
3
INTRODUCTION
4
PROPOSED DESIGN
In this chapter, we will delve into the proposed design and implementation of the digital
clock system. This section will provide a comprehensive overview of the hardware and
software components involved, as well as the overall architecture of the system.
• ARDUINO UNO
• OLED DISPLAY
• PUSH BUTTONS
ARDUINO UNO
The word "uno" means "one" in Italian and was chosen to mark a major redesign of the
Arduino hardware and software. The Uno board was the successor of the Duemilanove
release and was the 9th version in a series of USB-based Arduino boards. Version 1.0 of
the Arduino IDE for the Arduino Uno board has now evolved to newer releases. The
ATmega328 on the board comes preprogrammed with a bootloader that allows uploading
new code to it without the use of an external hardware programmer.
5
While the Uno communicates using the original STK500 protocol, it differs from all
preceding boards in that it does not use a FTDI USB-to-UART serial chip. Instead, it uses
the Atmega16U2 (Atmega8U2 up to version R2) programmed as a USB-to-serial
converter.
SPECIFICATIONS
Microcontroller (MCU)
IC: Microchip ATmega328P (8-bit AVR core)
Clock Speed: 16 MHz on Uno board, though IC is capable of 20 MHz maximum at 5
Volts
Flash Memory: 32 KB, of which 0.5 KB used by the bootloader
SRAM: 2 KB
EEPROM: 1 KB
USART peripherals: 1 (Arduino software default configures USART as a 8N1 UART)
SPI peripherals: 1
I²C peripherals: 1
Operating Voltage: 5 Volts
Digital I/O Pins: 14
PWM Pins: 6 (Pin # 3, 5, 6, 9, 10 and 11)
Analog Input Pins: 6
DC Current per I/O Pin: 20 mA
DC Current for 3.3V Pin: 50 mA
Size: 68.6 mm x 53.4 mm
Weight: 25 g
ICSP Header: Yes
Power Sources:
USB connector. USB bus specification has a voltage range of 4.75 to 5.25 volts. The
official Uno boards have a USB-B connector, but 3rd party boards may have a
miniUSB / microUSB / USB-C connector.
5.5mm/2.1mm barrel jack connector. Official Uno boards support 6 to 20 volts,
though 7 to 12 volts is recommended. The maximum voltage for 3rd party Uno boards
varies between board manufactures because various voltage regulators are used, each
having a different maximum input rating. Power into this connector is routed
through a series diode before connecting to VIN to protect against accidental reverse
voltage situations.
VIN pin on shield header. It has a similar voltage range of the barrel jack. Since this
pin doesn't have reverse voltage protection, power can be injected or pulled from this
pin. When supplying power into VIN pin, an external series diode is required in case
barrel jack is used. When board is powered by barrel jack, power can be pulled out of
this pin.
6
OLED DISPLAY
OLED is an organic light-emitting diode, also known as organic dot laser display.
Composed of a very thin coating of organic materials that emit light and a glass
substrate, it has self-luminous properties, a large viewing angle and low power
consumption.
It doesn’t need a backlight ( it will light up when the driver and wiring up are correct).
It has high contrast and fast response speed, applied for flexible surface. In addition, it is
easy to build.
The module comes with 4 positioning holes, which is convenient for you to fix it on other
devices.
This OLED display module is small, only 0.96” diagonal, it is made of 128x64 individual
blue OLED pixels, each one is turn on or off by the controller chip.
It works without backlight, that is, in a dark environment, OLED display is higher
compared to that of LCD display, you will like the miniature for its crispness
7
SPECIFICATIONS
PUSH BUTTON
8
CIRCUIT DIAGRAM
U1_5V
U1
VIN RX
5V TX
3.3V D2
D3
D4
AREF
U2 IOREF
D5
D6
VCC RES
D7
S1 S2
Arduino D8
D9
A0
SDA A1 UNO D10
OLED SCL A2
A3
D11
D12
A4 D13
A5 SDA
GND SCL
GND
U1_GND
9
WORKING
The main connections are the OLED Display is connected to Arduino UNO by
connecting the VCC to the 5v pin of the Arduino and the GND of OLED Display to the
GND of the Arduino and the pin SDA of Display to the A5 of Arduino and the SCL of the
Display to the A4 of the Arduino.
And Push buttons enable the time set and reset is connected by grounding the one pin of
button and other to pin 2 and 3.
After the successful flashing of the code we can set and select which one is to be set can
be done by pressing the push buttons
Due to the Utilisation of the internal clock of Arduino we can minimize the size of
circuit and also save money for extra RTC(Real Time Clock) Module.
One Disadvantage of the project is onces the circuit gets powered off we have to set the
time again.
We can resolve this by using an RTC module.
10
RESULT
1. Digital Clock Display: The OLED display will show the current time in hours,
minutes, and seconds format. The time will be continuously updated, and you'll see the
seconds counting up in real-time.
2. Button Functionality:
- Mode Button (PIN_BUTTON_MODE): Pressing this button will cycle through
different modes, such as showing the current time and setting the seconds, minutes, or
hours.
- Set Button (PIN_BUTTON_SET): Depending on the current mode, pressing this
button will allow you to adjust the time parameters. For example, in set mode, pressing
the set button will increment the selected time parameter (seconds, minutes, or hours).
3. Time Adjustment:
- When in set mode, you can use the set button to adjust the seconds, minutes, or
hours. Each press of the set button will increment the selected time parameter by one.
- The time adjustment is implemented with debouncing to ensure accurate and
reliable button presses.
4. Visual Animation:
- There's a visual animation implemented to show the passing seconds. You'll see a
progress bar on the OLED display that represents the percentage of the current second
elapsed.
5. Automatic Timekeeping:
- The code automatically keeps track of time, incrementing the seconds, minutes, and
hours accordingly. It ensures that the time values stay within their valid ranges (e.g.,
seconds range from 0 to 59, minutes and hours range from 0 to 59 and 1 to 12
respectively).
6. User-Friendly Interface:
- The OLED display provides a clear and easy-to-read interface for viewing the time
and interacting with the clock settings.
- The button controls allow for intuitive navigation and adjustment of time
parameters.
11
CODE
#include <Arduino.h>
#include <U8g2lib.h>
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
byte hours = 0;
byte minutes = 0;
byte seconds = 0;
char timeString[9];
void setup(void) {
u8g2.setFont(u8g2_font_logisoso28_tf);
u8g2.begin();
pinMode(PIN_BUTTON_MODE, INPUT_PULLUP);
pinMode(PIN_BUTTON_SET, INPUT_PULLUP);
void loop(void) {
currentMillis = millis();
12
if (digitalRead(PIN_BUTTON_MODE) == LOW) {
buttonModeHandler();
}
if (digitalRead(PIN_BUTTON_SET) == LOW) {
buttonSetHandler();
}
checkTime();
if (currentMode == MODE_SHOW_TIME) {
increaseSeconds();
} else {
previousTimeUpdateMillis = currentMillis;
}
drawScreen();
}
void checkTime() {
void buttonModeHandler() {
elapsedButtonModeMillis = currentMillis - previousButtonModeMillis;
if (elapsedButtonModeMillis > BUTTON_MODE_DEBOUNCE_TIME) {
Serial.println("Mode Handler");
previousButtonModeMillis = currentMillis;
currentMode++;
if (currentMode > 3) {
currentMode = 0;
}
}
}
void buttonSetHandler() {
elapsedButtonSetMillis = currentMillis - previousButtonSetMillis;
Serial.println(elapsedButtonSetMillis);
if (elapsedButtonSetMillis > BUTTON_SET_DEBOUNCE_TIME) {
Serial.println("Set Handler");
previousButtonSetMillis = currentMillis;
13
if (currentMode == MODE_SET_SECONDS) {
seconds = 0;
}
if (currentMode == MODE_SET_MINUTES) {
minutes++;
}
if (currentMode == MODE_SET_HOURS) {
hours++;
}
}
}
void increaseSeconds() {
elapsedTimeUpdateMillis = currentMillis - previousTimeUpdateMillis;
void drawScreen() {
u8g2.firstPage();
do {
if (currentMode != MODE_SHOW_TIME) {
u8g2.drawTriangle((currentMode - 1) * 43 + 5, 0, currentMode * 43 - 5, 0, (currentMode - 1) * 43 + 21, 5);
}
drawAnimation();
drawTime();
} while (u8g2.nextPage());
}
void drawTime() {
void drawAnimation() {
percentageOfSecondElapsed = elapsedTimeUpdateMillis / 1000.0;
if (currentMode == MODE_SHOW_TIME) {
u8g2.drawBox(0, 0, 127 - (127 * percentageOfSecondElapsed), 2);
u8g2.drawBox(0, 3, (127 * percentageOfSecondElapsed), 2);
}
}
14
CONCLUSION
15