Now that CircuitPython & libraries are installed on your CLUE, all you need is the project code.

Installing Project Code

To use with CircuitPython, you need to first install a few libraries, into the lib folder on your CIRCUITPY drive. Then you need to update with the example script.

Thankfully, we can do this in one go. In the example below, click the Download Project Bundle button below to download the necessary libraries and the file in a zip file. Extract the contents of the zip file, open the directory Activity_Generator/ and then click on the directory that matches the version of CircuitPython you're using and copy the contents of that directory to your CIRCUITPY drive.

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

# SPDX-FileCopyrightText: 2020 Collin Cunningham for Adafruit Industries
# SPDX-License-Identifier: MIT

import time
import random
from adafruit_clue import clue
from things import activities
from things import subjects

screen = clue.simple_text_display(text_scale=4, colors=(clue.WHITE,))

screen[1].text = "ACTIVITY"
screen[2].text = "GENERATOR"

screen[0].text = "make a"
screen[2].text = "about"
screen[1].color = clue.RED
screen[3].color = clue.GREEN
screen[4].color = clue.BLUE

activity = "???"
subject_a = "???"
subject_b = "???"
two_subjects = True

def random_pick(items):
    index = random.randint(0, len(items)-1)
    return items[index]

while True:

    if clue.button_a:
        activity = random_pick(activities)
        subject_a = random_pick(subjects)
        subject_b = random_pick(subjects)
    if clue.button_b:
        two_subjects = not two_subjects

    screen[1].text = activity
    screen[3].text = subject_a

    if two_subjects:
        screen[4].text = subject_b
        screen[4].text = ""

This guide was first published on Apr 08, 2020. It was last updated on Jul 18, 2024.

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

Text editor powered by tinymce.