How To
How to Create A Raspberry Pi Clock Using the Sense HAT?

The Raspberry Pi can so plenty of tremendous things right out of the box, But it can do even more with the help of the Sense HAT, which is an add-on developed for the Astro Pi project. Astro Pi sent expanded Pis into space, and the Sense HAT provided most of the new functionality used on the mission. In that new functionality, A small LED matrix, which just so happens to be perfect for use as the digital clock display. Here are the steps to create Raspberry Pi Clock using the Sense HAT:

You can also make this too, with the help of these instructions. For this project, you just need the usual stuff ( a Raspberry Pi, miscroSD card, etc.) plus the Sense HAT.
Related: How to Set up an FTP Server on the Raspberry Pi?
How to Create a Raspberry Pi Clock Using the Sense HAT?
This project is very simple, and it’s a tremendous introduction to the Sense HAT and the great things that it can help your Pi do. The primary thing we are going to do here is to install Raspbian and, after checking to make sure that you have the Sense HAT library, create the Python file based on the hard work of the GitHub user which goes by SteveAmor. then you can simply run the Python file and enjoy the new digital clock. Just follow the steps below to simply get it done.
Step 1: Install and Update your Raspbian, similar to many other projects, this also starts with the Raspbian. Install Raspbian, then open the Terminal and run the commands given below:
sudo apt-get update
sudo apt-get upgrade

Step 2: Just check to make sure you have the Sense HAT library, The Sense HAT library was installed already, but it’s always better to check once:
sudo apt-get install sense-hat
If you get a message which says “sense-hat is already the newest version,” you are all set. You can move on to the next step.
Step 3: Now Create a new Python file
nano clock.py
With the following contents, this would be long, So get ready for that.
from sense_hat import SenseHat
import time
sense = SenseHat()
number = [
0,1,1,1, # Zero
0,1,0,1,
0,1,0,1,
0,1,1,1,
0,0,1,0, # One
0,1,1,0,
0,0,1,0,
0,1,1,1,
0,1,1,1, # Two
0,0,1,1,
0,1,1,0,
0,1,1,1,
0,1,1,1, # Three
0,0,1,1,
0,0,1,1,
0,1,1,1,
0,1,0,1, # Four
0,1,1,1,
0,0,0,1,
0,0,0,1,
0,1,1,1, # Five
0,1,1,0,
0,0,1,1,
0,1,1,1,
0,1,0,0, # Six
0,1,1,1,
0,1,0,1,
0,1,1,1,
0,1,1,1, # Seven
0,0,0,1,
0,0,1,0,
0,1,0,0,
0,1,1,1, # Eight
0,1,1,1,
0,1,1,1,
0,1,1,1,
0,1,1,1, # Nine
0,1,0,1,
0,1,1,1,
0,0,0,1
]
hour_color = [255,0,0] # Red
minute_color = [0,255,255] # Cyan
empty = [0,0,0] # Black
clock_image = [
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0
]
while True:
hour = time.localtime().tm_hour
minute = time.localtime().tm_min
# Map digits to the clock_image array
pixel_offset = 0
index = 0
for index_loop in range(0, 4):
for counter_loop in range(0, 4):
if (hour >= 10):
clock_image[index] = number[int(hour/10)*16+pixel_offset]
clock_image[index+4] = number[int(hour%10)*16+pixel_offset]
clock_image[index+32] = number[int(minute/10)*16+pixel_offset]
clock_image[index+36] = number[int(minute%10)*16+pixel_offset]
pixel_offset = pixel_offset + 1
index = index + 1
index = index + 4
# Color the hours and minutes
for index in range(0, 64):
if (clock_image[index]):
if index < 32:
clock_image[index] = hour_color
else:
clock_image[index] = minute_color
else:
clock_image[index] = empty
# Display the time
sense.low_light = True # Optional
sense.set_pixels(clock_image)
time.sleep(1)
Step 4: Now you can start your clock by running the following command:
python3 clock.py
The clock will keep running until you exit, which you can do with the Ctrl+C

Related: How to Use Raspberry Pi as a Chromecast Alternative?
Now you have created your own Raspberry Pi Clock using the Sense HAT. This project is very simple because it depends highly on the GitHub user SteveAmor’s code. You can put the new Raspberry Pi Clock anywhere because it doesn’t need any monitor or screen, since it uses the Sense HAT’s LED matrix. So that you can do this entire project without any dedicated screen, if you choose to SSH into your Raspberry Pi. This is such an incredible project to use with the dedicated Pi and to combine with other simple home utility and smart home projects.
Thank you for reading this post.
-
How To2 weeks ago
How to Setup and Watch IPTV on VLC Media Player [2023]
-
How To4 years ago
Rufus for Linux | How to Create a Bootable USB for Linux Using Rufus
-
Chromecast2 years ago
How to Stream IPTV on Chromecast [2022]
-
How To2 years ago
F4M Tester Kodi Addon – Step by Step Installation Guide (2022)
-
How To2 years ago
Uranus Kodi Addon – Install using Blamo Griffin Repository
-
How To12 months ago
Rufus for Mac: Best 4 Alternatives to Create a Bootable USB Drive
-
How To1 year ago
Placenta Kodi Addon – Step by Step Installation Guide [2022]
-
How To3 years ago
Gurzil Kodi Addon – How to Install Gurzil Addon in Kodi?