Skip to content

siyametj/binary_clock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎛️ Python Binary Clock

A modern Binary Clock built with Python and Streamlit that displays the current local time using Binary Coded Decimal (BCD) representation.

The project follows a simple and clean architecture by separating the clock logic from the graphical interface, making the code easier to understand, maintain, and extend.


✨ Features

  • 🕒 Displays the current local time in real time
  • 💡 Binary Coded Decimal (BCD) representation
  • 🎨 Modern LED-style interface
  • ⚡ Updates automatically every second
  • 🧩 Clean separation between backend and frontend
  • 🐍 Built entirely with Python and Streamlit

📂 Project Structure

binary-clock/
│
├── clock.py      # Backend logic for generating the binary clock matrix
├── gui.py        # Streamlit UI and LED rendering
├── main.py       # Application entry point
└── README.md

🏗️ Architecture

clock.py

Contains the core logic of the application.

Responsibilities:

  • Get the current local time
  • Convert each decimal digit into a 4-bit binary number
  • Generate a 4×6 binary matrix used by the GUI

Main methods:

  • get_current_time_digit()
  • digit_to_binary_list()
  • get_binary_clock_matrix()

gui.py

Responsible for rendering the binary clock using Streamlit.

Features include:

  • Custom CSS for LED styling
  • Binary matrix visualization
  • Hour, Minute, and Second column separation
  • Digital clock displayed underneath for verification
  • Automatic refresh every second

main.py

The application's entry point.

Responsibilities:

  • Configure the Streamlit page
  • Launch the graphical interface

📦 Requirements

  • Python 3.8+
  • Streamlit

Install the required package:

pip install streamlit

🚀 Running the Application

Start the application with:

streamlit run main.py

The binary clock will automatically refresh every second to display the current local time.


🧠 How the Binary Clock Works

Each decimal digit of the current time is converted into a 4-bit binary value.

Example:

Time

14 : 39 : 58

Digits

1 4 3 9 5 8

Binary

0001
0100
0011
1001
0101
1000

Each column represents one decimal digit, while each row represents a binary bit.

An illuminated LED indicates 1, while a dark LED indicates 0.


🎨 UI Highlights

  • Smooth LED animations
  • Modern dark theme
  • Glowing active LEDs
  • Clear spacing between Hours, Minutes, and Seconds
  • Digital clock for easy comparison

🔧 Technologies Used

  • Python
  • Streamlit
  • HTML/CSS (via Streamlit Markdown)

📸 Preview

The application displays:

  • Six binary columns
  • Four binary rows
  • LED indicators
  • Live digital clock

🌱 Future Improvements

  • 12-hour format option
  • Theme switcher (Dark/Light)
  • Adjustable LED colors
  • Timezone selection
  • Animated startup effect
  • Responsive layout improvements

📄 License

This project is open source and available under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages