diff --git a/examples/userinput_example.py b/examples/userinput_example.py new file mode 100644 index 0000000000000000000000000000000000000000..d3986dfb2287c152597f0ffb74c7e34e5ae5d323 --- /dev/null +++ b/examples/userinput_example.py @@ -0,0 +1,16 @@ +import sys, machine +led = machine.Pin(25, machine.Pin.OUT, machine.Pin.PULL_DOWN) + +def userInput(): + print("Enter on or off to set LED:") + input = sys.stdin.readline() + if input == "on\n": + led.on() + print("LED switched ON") + elif input == "off\n": + led.off() + print("LED switched OFF") + else: pass + +while True: + userInput() \ No newline at end of file