Example: Turn on an LED
Note This example is only for kits that use the XBIB-CU-TH development board. For an example that uses the XBIB-U-DEV development board, see Example: turn on an LED.
- Note the DIO10 LED on the XBIB board. The following image highlights it in a red box. The LED is normally off.
- At the MicroPython >>> prompt, type the commands below, pressing Enter after each one. After entering the last line of code, the LED illuminates. Anything after a # symbol is a comment, and you do not need to type it.
Note You can easily copy and paste code from the online version of this guide. Use caution with the PDF version, as it may not maintain essential indentations.
from machine import Pin
led = Pin("D10", Pin.OUT, value=1) # Makes a pin object set to output 1.
- To turn it off, type the following and press Enter:
led.value(0)
You have successfully controlled an LED on the board using basic I/O.