Passive Buzzer
# Module Import
import LocoIOT
import time
# Class Instances Creation
loco_iot = LocoIOT.LocoIOT()
msg = LocoIOT.IOT_Codes()
# Initiate Connection to the Microcontroller
loco_iot.connect()
# Enable Passive Buzzer Hardware Configuration
loco_iot.enable(msg.SUBTYPE_PAS_BUZZ)
#Dictionary
octave = {
"C" : [523] ,
"C Sharp" : [554] ,
"D": [587] ,
"D Sharp" : [622] ,
"E" : [659] ,
"F" : [699] ,
"F Sharp" : [740] ,
"G" : [784] ,
"G Sharp" : [831] ,
"A" : [880] ,
"A Sharp" : [932] ,
"B" : [988] ,
}
# Start Listening for Control/Request Messages
loco_iot.start()
# Create a list of the dictionary values
value_list = list(octave.keys())
# Set Duration and Frequency
data = [1000, 523] # Duration in Milliseconds, Frequency in Hertz
loco_iot.setData(msg.SUBTYPE_PAS_BUZZ, data)
# Loop through value_list and print each item.
for val in reversed(value_list):
# Set Colors
loco_iot.setData(msg.SUBTYPE_PAS_BUZZ, octave[val])
time.sleep(1)
print(val)
# Pause program execution for the buzzer duration
time.sleep(1)
# Close Connection to the Microcontroller
loco_iot.close()