Before we asseble our XRP kits, we will setup our development environment and make sure we can connect our computers to the XRP controller board, create and run a "Hello, World!" program.
Take the XRP controller board out of the box. It looks like this--->
Find the USB C connector
Connect the USB cable to the XRP controller board
Connect the other end of the cable to your computer. If your computer only has USB C ports, you'll need a USB A to USB C adapter.
Or you'll need a USB C to USB C data cable.
Did the "SYS" LED light up? (It's to the left of the USB connector.)
If not, check your connections.
If you can't get this to turn on, ask for help.
Note: The USB connector is fragile. Be sure to take care to gently connect and disconnect the cable.
Open the Chome browser
Open the XRP Code Editor: https://xrpcode.wpi.edu/
(Please bookmark this as we'll be using it throughout the class)
Click "CONNECT XRP" on the upper right of the XRP Code Editor screen
Select the serial port. If no serial port is listed, check your cable connections and try again.
If you get a message like "The library files on the XRP are out of date. .." follow the instructions to update the firmware on in the Raspberry Pi Pico W.
Connected? Great! If not, ask for help.
Or review: https://xrpusersguide.readthedocs.io/en/latest/course/XRPCode.html.
Copy the XRP Code program here --->
Select the blocks from the appropriate menu and drag them into place:
Loops ... repeat while
Logic ... true
Control Board ... LED on
L:ogic ... Sleep
Control Board ... LED off
Logic ... Sleep
Click the "Run" button on the upper right the XRP Code Editor screen
You'll get a prompt to save your program on the XRP. Use "blink.blocks" for the filename.
You'll get a message "The power switch on the XRP is not on."
Click "OK" (We don't need battery power for this exercise.)
Is the "STAT" LED blinking? Great!
(It is located on the upper right of the board, just above the sparkfun logo.
If not, carefully check your program.
The XRP Code Editor is a "code generator" based on "Blockly" [https://developers.google.com/blockly]
It generates Python code [https://www.python.org/] from the graphical blocks that you drag and drop.
It uses an interpreter that runs in microcontrollers called MicroPython [https://micropython.org/]
Click "STOP"
Click View ... View Python
Read the Python code. Can you see how it corresponds to the block code?
Copy the Python code
Click File ... New File ... MICRO PYTHON
In the text window, select all and paste the Python code
Click run. Save the program as "blink.py"
You'll need to click the "STOP" button, modify your program, and click the "Run" button.
If the XRP Code Editor is stuck in the "Stopping XRP..." message, press the "Reset" button.
The USB connection will disconnect and attempt to reconnect.
You can also type Control-C to stop the program. And Control-D to run the program.
Do one or more of the following activities.
You can use Blockly or Micropython.
Change the blink rate (faster or slower)
Add a "print" block from the "Text" menu to display "Hello, World!" at the start of the repeat loop.
You'll see the print text output at the bottom of the XRP Code Editor screen, in the "Shell" area.
Blink a message in Morse code.
Copy/paste the LED on/sleep/LED off/sleep blocks, changing the sleep times to create the Morse code messages.
Example: SOS (Emergency) : short-short-short-long-long-long-short-short-short
You might ask ChatGPT or another AI code generator to write this code for you. Example prompt:
"Write a micropython program to blink SOS using the internal LED on a raspberry pi pico w"
Does the code work?
Examine the code -- do you understand how it works?
Or maybe you have another idea about blinking the LED?