Did Your Bot Wish You Happy New Year?

Carl Wishes “Happy New Year”

In a scramble on the “Last Day of the Year To Make My Bot Smart”, I managed to get Carl to participate in the end of the year excitement. Here he is with his friend watching the ball drop on TV:

UNADJUSTEDNONRAW_mini_a7f3

A few seconds too early, actually, Carl started counting down “10…9…8…”, and ended wishing “Happy New Year Everyone, Happy New Year” (In the process, he scared my wife who was not expecting Carl to start talking.)

To put him in the spirit, I added the following code fragments to his “sit quiet and contemplate your navel” program (status.py) to make newyear.py


def closeToMidnight():
    d = datetime.now()
    minuteBefore = d.replace(hour=23, minute=59, second=0, microsecond=0)
    minuteAfter = d.replace(year=2019, month=1, day=1, hour=0, minute=0, second=0)
    if d > minuteBefore and d < minuteAfter:
        print ("close to midnight")
        return True
    else: return False


def countDownAndYell():
    afterMidnight = False
    d = datetime.now()
    startCountDown = d.replace(hour=23, minute = 59, second=50, microsecond=0)
    while not(afterMidnight):
        d = datetime.now()
        print ("d:",d)
        if d > startCountDown:
            for i in range (10, 0, -1):
                nStr = "{}".format(i)
                d = datetime.now()
                print(nStr, d)
                speak.say(nStr)
                time.sleep(0.45)
            print ("Happy New Year")
            speak.say("Happy New Year Everybody.  Happy New Year.")
            afterMidnight = True
        else: time.sleep(1)


##### Main #####   
.
.
. 
try:
   while True:
   .
   .
   .
      if (closeToMidnight()):  countDownAndYell()

Here is some of the “After The Party Trash” he left laying around:

********* CARL Basic STATUS *****
2018-12-31 23:59:04 up 7:54, 2 users, load average: 0.14, 0.08, 0.08
Battery Voltage: 9.30
5v Supply: 5.06
Estimated Life Remaining: 4 h 25 m
Processor Temp: 45.1’C
Clock Frequency: 600.0 MHz
throttled=0x0
Distance Sensor: 53.9 inches
close to midnight
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 4, 684773))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 5, 685960))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 6, 687722))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 7, 689484))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 8, 691251))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 9, 692981))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 10, 694747))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 11, 696514))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 12, 698240))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 13, 700003))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 14, 701775))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 15, 703505))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 16, 705265))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 17, 707065))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 18, 708801))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 19, 710556))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 20, 712332))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 21, 714079))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 22, 715838))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 23, 717598))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 24, 719386))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 25, 721147))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 26, 722903))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 27, 724631))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 28, 726393))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 29, 728161))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 30, 729916))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 31, 731678))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 32, 733443))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 33, 735183))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 34, 736994))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 35, 738760))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 36, 740486))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 37, 742245))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 38, 744011))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 39, 745726))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 40, 747485))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 41, 749245))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 42, 750970))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 43, 752739))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 44, 754490))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 45, 756212))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 46, 757962))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 47, 759724))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 48, 761461))
(‘d:’, datetime.datetime(2018, 12, 31, 23, 59, 49, 763215))
(‘10’, datetime.datetime(2018, 12, 31, 23, 59, 50, 763215))
(‘9’, datetime.datetime(2018, 12, 31, 23, 59, 51, 763215))
(‘8’, datetime.datetime(2018, 12, 31, 23, 59, 52, 763215))
(‘7’, datetime.datetime(2018, 12, 31, 23, 59, 53, 763215))
(‘6’, datetime.datetime(2018, 12, 31, 23, 59, 54, 763215))
(‘5’, datetime.datetime(2018, 12, 31, 23, 59, 55, 763215))
(‘4’, datetime.datetime(2018, 12, 31, 23, 59, 56, 763215))
(‘3’, datetime.datetime(2018, 12, 31, 23, 59, 57, 763215))
(‘2’, datetime.datetime(2018, 12, 31, 23, 59, 58, 763215))
(‘1’, datetime.datetime(2018, 12, 31, 23, 59, 59, 763215))
Happy New Year

********* CARL Basic STATUS *****
2019-01-01 00:00:08 up 7:55, 2 users, load average: 0.05, 0.06, 0.07
Battery Voltage: 9.29
5v Supply: 5.06
Estimated Life Remaining: 4 h 4 m
Processor Temp: 45.6’C
Clock Frequency: 600.0 MHz
throttled=0x0
Distance Sensor: 53.5 inches

Wishing everyone’s GoPiGo bot a “Happy New Year!”

2 Likes

HAHA! That’s awesome!
Happy New Year to you too! I hope your wife will forgive Carl for startling her! :slight_smile:

1 Like

“After the Party Trash” - I like the choice of words in this one. LOL.

And Happy New Year to you too!! :smile:
Carl is awesome as usual! Really glad seeing this sort of stuff on the forum.

By the way, I created a special tag for Carl, so that from now on, we can easily find any post about him.

2 Likes

Perhaps “Celebrate Happy New Year With Your GoPiGo3” will be chosen to be the 2019 December Mission Box (containing the DI Speaker) for Bloxter and Python?

I would love to see how others choose to solve the synchronized trigger problem.

This challenge is in the class of problems that you can simulate to test your program, but you only get one chance for it to work.

(Folks that are really adventurous might try using vision or sound from the television. )