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.

In the example below, click the Download Project Bundle button below to download the necessary files in a zip file. Extract the contents of the zip file, open the directory Arduino_Nano_RP2040_Connect/arduino_nano_rp2040_connect_blink/ and then click on the directory that matches the version of CircuitPython you're using and copy code.py to your CIRCUITPY drive.

Your CIRCUITPY drive should now look similar to the following image:

CIRCUITPY
# 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)

This guide was first published on Jun 04, 2021. It was last updated on Jul 18, 2024.

This page (Blink) was last updated on Jul 17, 2024.

Text editor powered by tinymce.