Blinking an LED is the "hello world" of hardware. The Arduino Nano RP2040 Connect has an onboard LED that you can control in CircuitPython using board.LED
. The code below will turn the LED on for 1 second and then off for 1 second. It will also print "led on
" and "led off
" to the REPL.
You can access the code by downloading the Project Bundle. To do this, click on the Download Project Bundle button in the window below. It will download as a zipped folder.
# SPDX-FileCopyrightText: 2021 Liz Clark for Adafruit Industries # # SPDX-License-Identifier: MIT import time import board from digitalio import DigitalInOut, Direction # LED setup for onboard LED led = DigitalInOut(board.LED) led.direction = Direction.OUTPUT while True: led.value = True print("led on") time.sleep(1) led.value = False print("led off") time.sleep(1)
After downloading the Project Bundle, plug your board into the computer USB port. You should see a new flash drive appear in the computer's File Explorer or Finder (depending on your operating system) called CIRCUITPY. Unzip the folder and copy the arduino_nano_rp2040_connect_blink.py file to the Arduino Nano RP2040 Connect's CIRCUITPY drive. Then, rename that file to code.py. No libraries are needed in the lib folder for this code since it only uses built-in CircuitPython libraries.
Your Arduino Nano RP2040 Connect CIRCUITPY drive should look like this after copying the code.py file.