How to Make a DIY Digital Hourglass Using Arduino Nano and Tilt Sensor | Step by Step

Hello and welcome back. In this project, we will learn how to make a DIY digital hourglass using an Arduino Nano. For this Arduino Project, I mainly used a tilt sensor. Basically, we can detect the up and down angles using this sensor, which helps us identify when the hourglass is flipped. You can check this link for more info about the tilt sensor.
To create the sand visualization effect, I used 16 LEDs arranged in a row. I also added a buzzer to provide audio feedback both while the sand is falling and when it has completely finished. I made a custom PCB for this project as well, so we can connect all the components easily without using jumper wires. You can change the delay time as you like, depending on how fast or slow you want the sand to fall. This digital hourglass project can also be used for time-counting tasks like games, small challenges, or even short study sessions.
Ok, let’s do this project step by step. The required components are given below.
- Arduino Nano board x 1 — Our Store / Amazon
- Tilt sensor x 1 — Our Store / Amazon
- LED bulb x 16 — Our Store / Amazon
- 100 resistor x 16 — Our Store / Amazon
- 5V Active buzzer x 1 — Our store / Amazon
- 16 Pin IC base x 2 — Our store / Amazon
- 74HC595 shift register x 1 —Our Store / Amazon
- Female header x 1 — Our Store / Amazon
- 12v connector x 1 — Our store / Amazon
Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.
Step 1
Firstly, identify these components.









Step 2
Secondly, let’s go ahead and order the PCBs for this hourglass project.


- Click the “Instant Quote” button and upload the Gerber file, which you can download from the link below.
- Gerber file – Download
- For this project, I ordered five Purple PCBs. Next, select the build time and shipping method. Finally, click “Save to Cart” and complete the payment.





Step 3
Thirdly, let’s unbox the PCB package and take a look at the boards we received.






Step 3
Now, let’s solder the components onto the hourglass PCB.









Step 4
Next, connect the Arduino Nano board, tilt sensor, and shift registers to the hourglass PCB. Then, connect the Arduino board to the computer.





Step 5
Now, copy and paste the following program into the Arduino IDE.
- Code and gerber file — Download
#include <ShiftRegister74HC595.h>
ShiftRegister74HC595<2> led(5, 4, 3); // (data, clock, latch)
#define sensor 7
#define buzzer 6
bool lastTiltState = HIGH;
bool isTopHalfActive = true;
void setup() {
pinMode(sensor, INPUT);
pinMode(buzzer, OUTPUT);
}
void loop() {
// Handle tilt to flip hourglass
bool tiltState = digitalRead(sensor);
if (tiltState != lastTiltState) {
tone(buzzer, 1000, 100); // Tilt feedback
delay(150); // debounce
isTopHalfActive = !isTopHalfActive;
if (isTopHalfActive) {
transferSandUp();
} else {
transferSandDown();
}
lastTiltState = tiltState;
}
delay(50);
}
void transferSandDown() {
for (int i = 0; i < 8; i++) {
for (int j = i; j < 8; j++) {
led.set(j, HIGH); // Grain falling
tone(buzzer, 400, 20); // Soft buzzer
delay(random(100, 200)); // Slower step
led.set(j, LOW); // Clear trail
}
// Twinkle effect at landing
int landingLED = 15 - i;
for (int k = 0; k < 2; k++) {
led.set(landingLED, HIGH);
delay(75);
led.set(landingLED, LOW);
delay(75);
}
led.set(landingLED, HIGH); // Keep grain at rest
delay(150);
}
}
void transferSandUp() {
for (int i = 0; i < 8; i++) {
for (int j = i; j < 8; j++) {
led.set(15 - j, HIGH); // Grain falling up
tone(buzzer, 600, 20); // Soft buzzer
delay(random(100, 200)); // Slower step
led.set(15 - j, LOW);
}
int landingLED = i;
for (int k = 0; k < 2; k++) {
led.set(landingLED, HIGH);
delay(75);
led.set(landingLED, LOW);
delay(75);
}
led.set(landingLED, HIGH);
delay(150);
}
}
- Now, select the board and port. After, click the upload button.



Step 6
After that, glue two pieces of foam board or cardboard, one on the top and one on the bottom, to hold the hourglass stable.



Step 7
Afterward, connect an external power supply to your digital hourglass. For that, I used two Li-ion batteries, but you can also use a 9V battery if you prefer.


Ok, now you can test this Digital Hourglass project. The full video guide is below. So we hope to see you in the next project. Have a great day!

Troubleshooting tips
- Select the correct board and port.
- Check the power supply.
- Check the shift register ICs.