In this example, you'll upload the sketch to have the onboard NeoPixel (pin PA4) perform a rainbow swirl.
Library Installation
You can install the Adafruit_NeoPixel library for Arduino using the Library Manager in the Arduino IDE.
Click the Manage Libraries ... menu item, search for Adafruit_NeoPixel, and select the Adafruit NeoPixel library:
There are no additional dependencies for this library.
// SPDX-FileCopyrightText: 2024 ladyada for Adafruit Industries // // SPDX-License-Identifier: MIT #include <Arduino.h> #include <Adafruit_TinyUSB.h> // required for USB Serial #include <Adafruit_NeoPixel.h> const int neopixel_pin = PA4; #define LED_COUNT 1 Adafruit_NeoPixel pixels(LED_COUNT, neopixel_pin, NEO_GRB + NEO_KHZ800); void setup () { pixels.begin(); } uint16_t firstPixelHue = 0; void loop() { firstPixelHue += 256; for(int i=0; i<pixels.numPixels(); i++) { int pixelHue = firstPixelHue + (i * 65536L / pixels.numPixels()); pixels.setPixelColor(i, pixels.gamma32(pixels.ColorHSV(pixelHue))); } pixels.show(); delay(10); }
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.
Text editor powered by tinymce.