Description
–
Related Tags
–
from ptpma.components import PMALed, PMABuzzer
from ptbuttons import PTSelectButton, PTCancelButton, PTUpButton, PTDownButton
# name the LEDs and the buttons and state which ports the LEDs are connected to
red = PMALed("D0")
yellow = PMALed("D1")
green = PMALed("D2")
buzzer = PMABuzzer("D3")
up = PTUpButton()
down = PTDownButton()
select = PTSelectButton()
cancel = PTCancelButton()
# define (def) actions for each of the PMA components
def red_on():
red.on()
print ("RED ON")
def red_off():
red.off()
print ("RED OFF")
def yellow_on():
yellow.on()
print ("YELLOW ON")
def yellow_off():
yellow.off()
print ("YELLOW OFF")
def green_on():
green.on()
print ("GREEN ON")
def green_off():
green.off()
print ("GREEN OFF")
def buzzer_on():
buzzer.on()
print ("BUZZ")
def buzzer_off():
buzzer.off()
print ("NO BUZZ")
up.when_pressed = red_on
up.when_released = red_off
down.when_pressed = yellow_on
down.when_released = yellow_off
select.when_pressed = green_on
select.when_released = green_off
cancel.when_pressed = buzzer_on
cancel.when_released = buzzer_off
from ptbuttons import PTSelectButton, PTCancelButton, PTUpButton, PTDownButton
# name the LEDs and the buttons and state which ports the LEDs are connected to
red = PMALed("D0")
yellow = PMALed("D1")
green = PMALed("D2")
buzzer = PMABuzzer("D3")
up = PTUpButton()
down = PTDownButton()
select = PTSelectButton()
cancel = PTCancelButton()
# define (def) actions for each of the PMA components
def red_on():
red.on()
print ("RED ON")
def red_off():
red.off()
print ("RED OFF")
def yellow_on():
yellow.on()
print ("YELLOW ON")
def yellow_off():
yellow.off()
print ("YELLOW OFF")
def green_on():
green.on()
print ("GREEN ON")
def green_off():
green.off()
print ("GREEN OFF")
def buzzer_on():
buzzer.on()
print ("BUZZ")
def buzzer_off():
buzzer.off()
print ("NO BUZZ")
up.when_pressed = red_on
up.when_released = red_off
down.when_pressed = yellow_on
down.when_released = yellow_off
select.when_pressed = green_on
select.when_released = green_off
cancel.when_pressed = buzzer_on
cancel.when_released = buzzer_off