Skip to content

Commit 8295a68

Browse files
author
Mikey Sklar
committed
talking clock updated and runs clean - python3, circuitpython, pylint
1 parent 0b69b5d commit 8295a68

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

Binary file not shown.

Speech_Synthesis_on_the_Raspberry_Pi/playing_sounds_using_buttons.py renamed to Speech_Synthesis_on_the_Raspberry_Pi/saying_sounds_using_buttons.py

File renamed without changes.
Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
import os
2+
import time
3+
import board
4+
import busio
5+
import adafruit_mcp9808
6+
7+
# This example shows how to get the temperature from a MCP9808 board
8+
i2c_bus = busio.I2C(board.SCL, board.SDA)
9+
mcp = adafruit_mcp9808.MCP9808(i2c_bus)
210

3-
# Loop reading measurements every minute.
4-
print 'Press Ctrl-C to quit.'
511
while True:
6-
temp = sensor.readTempC()
7-
os.system("flite -t 'The temperature is " + temp + " degrees'" &)
12+
# print precise temperature values to console
13+
tempC = mcp.temperature
14+
tempF = tempC * 9 / 5 + 32
15+
print('Temperature: {} C {} F '.format(tempC, tempF))
16+
17+
# round temperature and convert to string for speech
18+
tempC = str(int(tempC))
19+
tempF = str(int(tempF))
20+
os.system("echo 'The temperature is " + tempF + " degrees' | festival --tts")
21+
822
time.sleep(60.0)

0 commit comments

Comments
 (0)