Posted on 31/01/2015 by Brian Corteil Posted in Making, Raspberry Pi
On the 28th feb will be the Raspberry Pi’s 3rd Birthday. I wrote a plugin for Pimoroni’s cool Displayotron for the Raspberry Pi, details for the plugin can be found on the Pimoroni forum here.
I have just finished converting the code for counting down on the command line, you can download the code from my github account by entering the following command on your Raspberry Pi’s command line.
git clone https://github.com/Corteil/countDown.git
then change the working directory
and then run the code
or you can type the code in, using a text editor, the code is below
#count down timer
# by Brian Corteil aka on Twitter @CannonFodder
# free to use
import os,time, datetime
from datetime import timedelta
# enter target time and date here
targetTime = datetime.datetime(year, month, day, hour, minutes) # sets up target time
while timeNow <= targetTime:
timeNow =datetime.datetime.now() # the time now!
days = remainingTime.days
secs = remainingTime.seconds
hrs, secs = divmod(secs, 3600)
mins, secs = divmod(secs, 60)
sys.stdout.write(“\r%dd %dh %dm %ds to the Raspberry Pi Birthday Bash! ” % (days, hrs, mins, secs))
print (“\rwhat time is it? It’s Party Time”) # prints Party Time