import time
time.sleep(0.1)
print("Hello, Pi Pico!")
from Log import *
from Lights import *
from Button import *
from LightStrip import *
from Buzzer import *
from Displays import *
import machine
Log.i('Starting mini Lab 1')
class Lab1:
"""Lab1 class- encapsulates all the hardwarte lab 1 uses"""
def __init__(self):
""" Create instances of all the classes in variables"""
self.redled = Light(5, 'Red LED')
self.bluebutton = Button(10, 'Blue Button', handler=self)
self.yellowbutton = Button(14, 'Yellow Button', handler=self)
self.led_strip = LightStrip(2, 'Led Strip', numleds=8, brightness= 1)
self.buzzer = PassiveBuzzer(15, 'Buzzer')
self.mydisplay = LCDDisplay(sda=0, scl=1)
def buttonPressed(self,name):
#Button Pressed Handler
if name == 'Blue Button':
self.redled.on()
self.buzzer.play(200)
self.mydisplay.showText("LED On")
elif name == 'Yellow Button':
self.led_strip.on()
self.buzzer.play(1000)
self.mydisplay.showText("LightStrip On")
def buttonReleased(self,name):
self.redled.off()
self.led_strip.off()
self.buzzer.stop()
self.mydisplay.showText("Hi Priyanka")
def run(self):
while True:
time.sleep(1)
mylab = Lab1()
mylab.run()