Adafruit_Learning_System_Gu.../Crickit_Hello_World/code.py
Mike Barela c697c08f2e
Update code.py
remove trailing whitespace
2018-07-12 09:34:26 -04:00

30 lines
1,000 B
Python

import time
import audioio
import board
import neopixel
from adafruit_crickit import crickit
# Set audio out on speaker
speaker = audioio.AudioOut(board.A0)
# Start playing the file (in the background)
def play_file(wavfile):
audio_file = open(wavfile, "rb")
wav = audioio.WaveFile(audio_file)
speaker.play(wav)
while speaker.playing:
pass
# NeoPixels on the Circuit Playground Express Light Blue
pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness=0.3)
# Fill them with our favorite color "#0099FF light blue" -> 0x0099FF
# (see http://www.color-hex.com/ for more colors and find your fav!)
pixels.fill(0x0099FF)
while True:
print("Hello world!")
play_file("hello.wav") # play Hello World WAV file
crickit.servo_1.angle = 75 # Set servo angle to 75 degrees
time.sleep(1.0) # do nothing for a 1 second
crickit.servo_1.angle = 135 # Set servo angle to 135 degrees
time.sleep(1.0) # do nothing for a 1 second