1. def set_all_switch_off():
2. switch(1,0)
3. switch(2,0)
4. switch(3,0)
5. Instantiating the object and executing the method function while 1 means always
looping, switchSetup、switch、set_all_switch_off means calling the above function. This code
keeps the light on for 1 second and then be off for 1 second.
1. if __name__ == "__main__":
2. switchSetup()
3. while 1:
4. switch(1,1)
5. switch(2,1)
6. switch(3,1)
7. print
(
"Light on...."
)
8. time.sleep(1)
9. set_all_switch_off()
10. print("Light off....")
11. time.sleep(1)
3.5 How to control the LED on Robot HAT driver
board
When you study the content of this course, even if you do not use the Small LED
module, you can also learn this lesson by controlling the LED on the Robot HAT
driver board,because there is a green LED next to each interface: when the interface is
turned on, the LED next to the interface will light up, indicating that the interface is
on.
You can observe the status of the LED on the Robot HAT driver board by using
the method of "3.4 How to control the small warm color LED " above.