Libraries
Once your CLUE is set up with CircuitPython and library files in general, we'll add some project specific libraries.
From the library bundle you downloaded in that guide page, transfer any additional libraries shown here onto the CLUE's /lib directory on the CIRCUITPY drive:
- adafruit_apds9960
- adafruit_bus_device
- adafruit_bmp280
- adafruit_clue.py
- adafruit_dotstar.mpy
- adafruit_fancyled
- adafruit_imageload
- adafruit_lis3mdl.mpy
- adafruit_lsm6ds.mpy
- adafruit_register
- adafruit_sht31d.mpy
- adafruit_slideshow.mpy
- neopixel.mpy
Text Editor
Adafruit recommends using the Mu editor for using your CircuitPython code with the CLUE boards. You can get more info in this guide.
Alternatively, you can use any text editor that saves files.
Code and Sample Graphics
Use the Download: Project Zip link in the code window below to download the code and sample graphics files for this project. Unzip the files into a directory.
# SPDX-FileCopyrightText: 2020 Anne Barela for Adafruit Industries # # SPDX-License-Identifier: MIT # Bright Wearables Purse Slideshow with FancyLED # Anne Barela for Adafruit Industries, February 2020 # MIT License import board import adafruit_dotstar as dotstar from adafruit_clue import clue from adafruit_slideshow import SlideShow, PlayBackDirection import adafruit_fancyled.adafruit_fancyled as fancy # Set the LED ring speed and brightness LED_SPEED = 0.2 # pick a number from 0 (no motion) to 1.0 (fastest!) BRIGHTNESS = 0.2 # pick a number from 0 (dark) to 1.0 (bright!) # colors available are RED, YELLOW, ORANGE, GREEN, TEAL # CYAN, BLUE, PURPLE, MAGENTA, WHITE, BLACK, GOLD, PINK # AQUA, JADE, AMBER, VIOLET, SKY - pick any color set! # 3 to 5 colors looks best... palette = [clue.PINK, clue.GOLD, clue.JADE] # For the Bright Wearables DotStar LED Ring num_leds = 12 pixels = dotstar.DotStar(board.P13, board.P15, num_leds, auto_write=False) offset = 0 # Create the BMP displayer slideshow = SlideShow(clue.display, None, folder="/", auto_advance=False) # turn palette to fancytype for i, color in enumerate(palette): palette[i] = fancy.CRGB(*[x / 255 for x in color]) while True: if clue.button_b: slideshow.direction = PlayBackDirection.FORWARD slideshow.advance() if clue.button_a: slideshow.direction = PlayBackDirection.BACKWARD slideshow.advance() # spin the LEDs for i in range(num_leds): # Load each pixel's color from the palette using an offset, run it # through the gamma function, pack RGB value and assign to pixel. color = fancy.palette_lookup(palette, offset + i / num_leds) color = fancy.gamma_adjust(color, brightness=BRIGHTNESS) pixels[i] = color.pack() pixels.show() offset += LED_SPEED / 10
Plug your CLUE into your computer via a known good USB cable. In your operating system's file explorer/finder, you should see a new flash drive named CIRCUITPY. Copy the code.py file and the three sample bmp files to the CLUE CIRCUITPY drive main (root) folder.
The files on your CLUE should be similar to the directory tree listed on this page. The first three files may not show up on a mac, they tell OSX to not put system files on the CLUE CIRCUITPY drive which might fill it up.