
Get started with MicroPython
Example: debug the secondary UART
Digi XBee® 3 Cellular LTE-M/NB-IoT Global Smart Modem User Guide
40
1. Note the
DIO10
LED on the XBIB board. The following image highlights it in a red box. The LED is
normally off.
2. 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
. 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.
3. 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.
Example: debug the secondary UART
This sample code is handy for debugging the secondary UART. It simply relays data between the
primary and secondary UARTs.
from machine import UART
import sys, time
def uart_init():
u = UART(1)
u.write('Testing from XBee\n')
return u
def uart_relay(u):
while True:
uart_data = u.read(-1)