You can move the dot in the box around, and the slider line across the gradient to
choose the perfect color. Choose a new color and click SAVE.
The NeoPixel color will update, and you will see the new value printed to the serial
console, as shown below.
Code Walkthrough
This example contains three try / except blocks. These are included where the
code is likely to fail due to WiFi or Adafruit IO connection failures. WiFi can be finicky,
and without these code blocks, if the connection was lost, the code would crash.
Instead, it is designed to reset the board and start the code over again to reestablish
the connection, regardless of the cause. This ensures your code will continue
running. The details of these blocks are explained below.
First you import all of the necessary modules and libraries. This includes importing the
data from your secrets.py file.
import time
import ssl
from random import randint
import socketpool
import wifi
import board
import neopixel
import adafruit_minimqtt.adafruit_minimqtt as MQTT
from adafruit_io.adafruit_io import IO_MQTT
try:
©Adafruit Industries Page 154 of 263