Skip to content
Snippets Groups Projects
Select Git revision
  • 8338d2bc54dc43c2911245e8376d509e01c5fd52
  • no-masters default protected
2 results

userinput_example.py

Blame
  • Catamine's avatar
    Kirsa authored
    8338d2bc
    History
    userinput_example.py 352 B
    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()