Blinking an LED is a great way to determine that you have your hardware and software ducks in a row. In this example, you'll breadboard an LED to the MISO pin (PA6), upload the example code and see your LED blink on and off every second.
// SPDX-FileCopyrightText: 2024 Ha Thach for Adafruit Industries // // SPDX-License-Identifier: MIT #include <Arduino.h> #include <Adafruit_TinyUSB.h> // required for USB Serial const int led = PA6; void setup () { pinMode(led, OUTPUT); } void loop () { Serial.println("LED on"); digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second Serial.println("LED off"); digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }
You'll notice that at the top of the code that the TinyUSB library is imported with #include <Adafruit_TinyUSB.h>
. This will allow access to the USB serial port on the QT Py.
Confirm that your upload settings match the settings listed here under Tools:
- Board: CH32V20x
- Board Select: Adafruit QTPy CH32V203G6
- USB support: Adafruit TinyUSB with USBD
For the port, select the COM port that matches your QT Py. It will not be labeled like you may be used to with other boards in the Arduino IDE.
If you open the Serial Monitor, you'll see LED on
and LED off
print out in unison with the blinking LED.
If you're not able to upload to the board, you may need to 'manually' put it into bootloader mode and use the WCHISP tool. Check this page https://learn.adafruit.com/adafruit-qt-py-ch32v203/bootloader-mode
Text editor powered by tinymce.