# ISM6106 LAB 1
# Leonid Medvinsky
# Memory Game
"""
Attempted to run this, but only received errors, so left the method calls here
to not break anything.
- Calling an instance of the 'game' class, I would like it to begin with the intro
and start the first sequence of lights and sounds from the passive buzzer:
game.start()
- 'Green Button' class, check if that was part of the color sequence, the same logic
will be used for the other colored buttons:
if green_button.isPressed():
game.checkInput("Green")
- 'lightStrip Class, an example of getting the lightstrip to display the color "Red"
but needs more work when running the code.
light_strip.setColor("Red")
light_strip.show()
- My 'passive_buzzer' class, attempting to play a tone at 1000 hz for 0.5 seconds.
buzzer.play(tone=1000)
time.sleep(0.5)
buzzer.stop()
"""
import time
time.sleep(0.1) # Wait for USB to become ready
print("Follow the Light Pattern!")
from Log import *
from Lights import *
from Button import *
from LightStrip import *
from Buzzer import *
from Displays import *
Log.i('Starting LAB 1')
# Declaration of variables/pin connections. (variable name = pin, "name")
redled = Light(5, 'Red LED')
bluebutton = Button(21, 'Blue button')
buzzer = PassiveBuzzer(pin=17, name="Buzzer")
greenbutton = Button(22, 'Green button')
lightstrip = LightStrip(pin = 2, name="Light Strip", numleds=8, brightness=1)
display = LCDDisplay(sda=0, scl=1)
redbutton = Button(20, 'Red Button')
yellowbutton = Button(19, 'Yellow Button')
# Loop: while blue button pressed/Red LED turns on
while True:
if bluebutton.isPressed():
redled.on()
buzzer.play(200)
display.showText("LED On")
elif greenbutton.isPressed():
lightstrip.on()
buzzer.play(1000)
display.showText("LightStrip On")
elif yellowbutton.isPressed():
lightstrip.on()
display.showText("Yellow Button was pressed")
elif redbutton.isPressed():
lightstrip.on()
display.showText("Red Button was pressed")
else:
redled.off()
lightstrip.off()
buzzer.stop()
display.clear()