Minimalist Single LED Clock ( Pi Zero and No Extra Parts ) 
Saturday, June 3, 2017, 10:08
Posted by Administrator


I was inspired by this post on Hackaday where Setvir created an elegant single LED clock using an Arduino Pro Micro. I'm more of a fan of Raspberry Pi's and have been wanting to come up with a simple single LED clock design of my own ever since reading that article.

It occurred to me today that the Pi Zero's status light could be commandeered for this purpose which would eliminate the need for any other additional parts. I considered using Python for this but eventually decided upon using bash scripting as it is already baked in to most common Pi Zero images such as Raspbian or Retropie.

The heavily commented code below is what I came up with to bring this clock design to life:

#!/bin/bash
# A minimalist led clock for the Pi Zero ( And Pi Zero W )
# Uses only the onboard led to blink the current hour
# And then to quickly blink the the tens place of minutes
#
# Spike Snell - June 2017

# First set the trigger for the onboard green led to none so that we have control of it
echo none | sudo tee /sys/class/leds/led0/trigger

# Turn off the led so that we have a known state to start
echo 1 | sudo tee /sys/class/leds/led0/brightness

# Loop endlessly
while true
do

# Wait for a full second to seperate our visual count
sleep 1

# Loop for the current number of hours
# Trim leading 0's so that 08 and 09 aren't interpreted as an octal base
for ((n=0;n<$(date +"%I" | sed 's/^0*//');n++))

do

# Wait a bit
sleep .25

# Turn the led on
echo 0 | sudo tee /sys/class/leds/led0/brightness

# Wait a bit
sleep .25

# Turn the led off
echo 1 | sudo tee /sys/class/leds/led0/brightness

done

# Wait for a half second
sleep .5

# Now loop very quickly for the current first tens digit of minutes
for ((n=0;n<$(date +"%M" | head -c 1);n++))

do

# Wait for a small bit
sleep .1

# Turn the led on
echo 0 | sudo tee /sys/class/leds/led0/brightness

# Wait for a small bit
sleep .1

# Turn the led off
echo 1 | sudo tee /sys/class/leds/led0/brightness

done

done

I saved the script in my home directory as minimalistClock.sh and made it executable with the command chmod +x minimalClock.sh. It is then run under its own screen with the command screen ./minimalClock.sh since it can be somewhat distracting if running on your main session due to all the echo commands. Screen is also a very handy way to make the clock persist and keep running even after logging out of your current session. Use the command sudo apt-get install screen if you don't already have it installed. After getting the clock up and running in screen you can press ctrl+a then ctrl+d to detach the screen and have it keep running in the background.

The clock is read by counting the number of long blinks to get the hours, and then the number of short blinks to get the tenth place of minutes. For example, 4 longer blinks followed by 3 shorter blinks indicates that the current time is about 4:30. I decided not to use a 24 hour military format for this because that would end up being far too many blinks when late in the day.

This script can be easily added to /etc/rc.local so that it will begin running when the Pi starts up.

This is exactly the minimalistic clock that I have been desiring for so long and it looks great running in my translucent Pi Zero Tic Tac Case which I have attached to the wall. Let me know what you all think of this basic clock design. If it could be made even simpler in some way I would love to experiment with that.

-- Edit March 2018

I have edited the code slighty in order for it to work on a Raspberry Pi 3 B+ ( Probably the non-plus version as well ).

Same idea as before, but this time using the onboard status led on the back of the bigger Pi. For some reason the light/dark values all had to be reversed, but other than that the code is the same. I found that putting a piece of electrical tape over the red led ( Which is always on when the Pi is receiving power ) makes the clock a lot more pleasant to leave on.

#!/bin/bash
# A minimalist led clock for the Pi 3 B+
# Uses only the onboard green led to blink the current hour
# And then to quickly blink the the tens place of minutes
#
# Spike Snell - March 2018

# First set the trigger for the onboard green led to none so that we have control of it
echo none | sudo tee /sys/class/leds/led0/trigger

# Turn off the led so that we have a known state to start
echo 0 | sudo tee /sys/class/leds/led0/brightness

# Loop endlessly
while true
do

# Wait for a full second to seperate our visual count
sleep 1

# Loop for the current number of hours
# Trim leading 0's so that 08 and 09 aren't interpreted as an octal base
for ((n=0;n<$(date +"%I" | sed 's/^0*//');n++))

do

# Wait a bit
sleep .25

# Turn the led on
echo 1 | sudo tee /sys/class/leds/led0/brightness

# Wait a bit
sleep .25

# Turn the led off
echo 0 | sudo tee /sys/class/leds/led0/brightness

done

# Wait for a half second
sleep .5

# Now loop very quickly for the current first tens digit of minutes
for ((n=0;n<$(date +"%M" | head -c 1);n++))

do

# Wait for a small bit
sleep .2

# Turn the led on
echo 1 | sudo tee /sys/class/leds/led0/brightness

# Wait for a small bit
sleep .2

# Turn the led off
echo 0 | sudo tee /sys/class/leds/led0/brightness

done

done

2 comments ( 36350 views )   |  permalink   |  $star_image$star_image$star_image$star_image$star_image ( 3 / 5454 )
Raspberry Pi Zero W Tic Tac Case 
Sunday, May 28, 2017, 09:02
Posted by Administrator
I have created a very simple Raspberry Pi Zero W case using a Tic Tac container. I considered putting the full instructions here but decided that Instructables would be the best platform for it to get mass exposure and the best search engine indexing. The plans have been released into the public domain.

Check out the 5 simple steps to make my super low cost Pi Zero W case here.


add comment ( 1797 views )   |  permalink   |  $star_image$star_image$star_image$star_image$star_image ( 3 / 510 )
Raspberry Pi + Atari 2600 Case 
Tuesday, March 7, 2017, 16:49
Posted by Administrator
I've recently finished putting together a custom Raspberry Pi case using the shell of an old Atari 2600. This isn't so much a how-to but more of a general overview of what was involved. It is all a lot simpler to accomplish than one might imagine.

What gave me the idea for this project was that I had an old Vader style Atari 2600 with a number of hardware issues rendering it unusable. I've also been emulating thousands of old games on a Raspberry Pi 3 with Retropie lately but had never had a case for the Pi that was much to look at. I had been considering buying one of those little 3d printed cases which look like an original Nintendo Entertainment System which are aesthetically impressive but the price point always seemed a little silly considering the Pi itself is so inexpensive.

The first step for this project was to completely remove all the innards from the old Atari. There was a lot more space in here than I expected so I knew straight off it wouldn't be a challenge at all to fit everything needed inside of the case.



The second step was to rip off all of the old switches and glue them down to the case plastic itself. I swapped the power switch out for the reset switch so that I could wire it up to the Pi later and use it to turn the system on and off. Below is a closeup of where I soldered wires on to the switch and then covered whole are with hot glue ( being careful not to effect the mechanism itself ):



The other end of this switch is connected to pins 5 and 6 of the pi's GPIO. These trigger the Pi to turn on if it has power but has been shutdown, they also double as an input which can trigger a safe shutdown of the system. I first saw how straightforward this was to set up on this video by ETA PRIME. He details how to set this all up and includes all the steps needed in a text file. Basically it involves making sure that you have python on the system and a library allowing you easy access to the GPIO pins. A script is then initiated whenever the system starts up which constantly watches for pins 5 and 6 being momentarily connected which then sets off a shutdown -h command when that occurs. Shutting the pi down in this way is much preferable to pulling the power to it since powering off suddenly at just the wrong moment can often lead to corruption of the sd card which the Pi runs itself off of.

Next up I piled everything into the belly of the large Atari case. I was able to add in an extra controller, spare A/V cable, and the Pi itself. Luckily all of the desired cords were able to be fed in through the controller port holes left in the back of the case. The HDMI head was a bit of a tight fit but I managed to get it through without any modification:



One of the final touches was to do a little modification of the logo on the front of the Atari after I realized that I could turn the capital R at the end of Atari into a fair approximation of the letter P:



I decided to not screw everything back together because the top shell fits on very snugly and sits firmly in place. I also like being able to open the case up easily so that I can get to the spare controller that I've stored inside. Things were looking a bit odd when I had a hole open where the games used to fit in the system. I decided to put a Bowling cartridge in the empty space which is not ideal for ventilation considerations but hasn't caused any problems so far.

Finally a shot of the entire case with my favorite controller on top ( Buffalo SNES ) :



It certainly isn't the most complex build out there but I am very pleased with it. It has been a lot more satisfying to have this classic Atari design beside the TV while I play old retro games compared to just hiding the Pi out of sight like I used to.

It would be a shame to dismantle a working Atari for this purpose but if you have a broken one, or can find one being sold which needs more repair than it is worth, I'd highly recommend re-purposing it in this way.
add comment ( 2630 views )   |  permalink   |  related link   |  $star_image$star_image$star_image$star_image$star_image ( 3 / 909 )

<<First <Back | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Next> Last>>