The best tools to make your project dreams come true

Login or Signup
USD


By Adafruit Industries

CRICKIT Exhibit Demo Board

Courtesy of Adafruit

Overview

Everything CRICKIT can do, all in one project!

 

This project shows how to connect a series of buttons, sensors, NeoPixel LED lights, motors, a speaker and more to showcase all the awesome things CRICKIT can do!

Image 1 71977

This project provides an excellent and entertaining demonstration of the wide variety of functions that CRICKIT for Circuit Playground Express can perform.

Image 2 72279

Electronics

Other Materials

Circuit Diagram

Before building the box and mounting the components, it's a good idea to wire up the electronics and make sure everything is working!

Image 3 72062

Buttons

  • In "Signal I/O" on CRICKIT, connect the wires of one button to signal and GND (doesn't matter which is which) on input 1
  • Repeat for second button on input 2

Potentiometer

  • Orient potentiometer or "pot" like in the diagram above.
  • Connect alligator clip from middle pin of the pot to signal on input 8
  • Connect alligator clip from left pin of the pot to 3.3V on input 8
  • Connect alligator clip from right pin of the pot to GND on input 8

Capacitive Touch

  • Connect alligator clip from capacitive touch input 1 on CRICKIT to conductive tape.

NeoPixels

  • Connect alligator clip from 5V on the NeoPixel strip to a breadboard wire then insert and screw down that wire to 5V on the NeoPixel input on CRICKIT.
  • Repeat for Data and GND wires.

Speaker

  • Connect speaker wire to CRICKIT speaker input (orientation does not matter)

DC Motor

  • Connect DC motor wires to CRICKIT Motor input 1 (orientation does not matter)

Electromagnet and Solenoid

  • On the CRICKIT Drive section, screw in one cable from each the solenoid and the electromagnet into 5V
  • Screw in the other cables to Drive inputs 1 and 2 for the solenoid and the electromagnet respectively.

The Servo

  • Plug in the servo to Servo input 1 on the CRICKIT with the brown wire facing inward towards the CRICKIT.

Image 4 71827

CircuitPython Code

Getting to know CircuitPython

CircuitPython is a programming language based on Python, one of the fastest growing programming languages in the world. It is specifically designed to simplify experimenting and learning to code on low-cost microcontroller boards.

CircuitPython is easiest to use within the Mu Editor. If you haven't previously used Mu, this guide will get you started.

If you've never used Circuit Playground Express (CPX) with CRICKIT before, make sure you've updated it with the latest special Crickit/seesaw version of the Circuit Playground Express firmware. This guide will show you how.

Image 5 71913

Preparing your Board

To get your CRICKIT for CPX set up to run this code, follow these steps:

1) Install the latest CircuitPython for CRICKIT from the CircuitPython GitHub page

2) Get the latest 4.0 library pack, unzip it, and drag the library simpleio.mpy over into the /lib folder on CIRCUITPY. If there is no lib directory, create one to put the file into.

More info on installing libraries here.

Image 6 72174

  • Find the simplio library in the library pack as simplio.mpy

Image 7 72173

  • Drag to the lib folder in the CIRCUITPY drive

Before continuing make sure your board's lib folder has the simplio library copied over.

Uploading

Make sure you've connected the Circuit Playground Express to your computer (mac/PC/Linux) via a known good USB A to micro-B cable. Your board should show up as a flash disk drive named CIRCUITPY (If you see a disk name CPLAYBOOT, try pressing the reset button again. If the only drive name you get is named CPLAYBOOT, CircuitPython may not be loaded on the board. You can load CircuitPython as per this guide).

Once your board is connected, copy code.py from the window below and paste it into Mu. Press the Save button and your code should automatically be saved to the CIRCUITPY disk drive (which appears when the Circuit Playground Express is plugged into your computer) as code.py.

Copy Code
"""
Crickit Exhibit
Project by Dano Wall and Isaac Wellish
Code by Isaac Wellish
The Crickit Exhibit demonstrates almost all of the capabilities
which CRICKIT can offer in one project
"""

# Functions:
#1. Hit a button to trigger a solenoid
#2. Hit a button to turn on an electromagnet
#3. Touch conductive tape to trigger a neopixel animation
#4. Turn a potentiometer to control a servo
#5. Shine light on the CPX to trigger and change the speed of a DC motor
#6. Hit both buttons to trigger a sound from the speaker!

import time
from adafruit_crickit import crickit
import board
import neopixel
from analogio import AnalogIn
from simpleio import map_range, tone

# RGB values
RED = (255, 0, 0)
YELLOW = (255, 150, 0)
GREEN = (0, 255, 0)
CYAN = (0, 255, 255)
BLUE = (0, 0, 255)
PURPLE = (180, 0, 255)

# For signal control, we'll chat directly with seesaw, use 'ss' to shorted typing!
# create seesaw object
ss = crickit.seesaw

# Two buttons are pullups, connect to ground to activate
BUTTON_1 = crickit.SIGNAL1
BUTTON_2 = crickit.SIGNAL2

ss.pin_mode(BUTTON_1, ss.INPUT_PULLUP)
ss.pin_mode(BUTTON_2, ss.INPUT_PULLUP)

#solenoid at drive spot 1
crickit.drive_1.frequency = 1000

#electromagnet at drive spot 2
crickit.drive_2.frequency = 1000

# initialize NeoPixels to num_pixels
num_pixels = 30

# The following line sets up a NeoPixel strip on Crickit CPX pin A1
pixels = neopixel.NeoPixel(board.A1, num_pixels, brightness=0.3, auto_write=False)

#sleep var for pushing both buttons
SLEEP_DELAY = 0.1

# NeoPixel function
def color_chase(color, wait):
for i in range(num_pixels):
pixelsi = color
time.sleep(wait)
pixels.show()
time.sleep(0.5)

# potentiometer connected to signal #3
pot = crickit.SIGNAL8

# initialize the light sensor on the CPX and the DC motor
light_in = AnalogIn(board.LIGHT)

while True:

# button + solenoid & electromagnet code
# button 1 - solenoid on
if not ss.digital_read(BUTTON_1):
print("Button 1 pressed")
crickit.drive_1.fraction = 1.0 # all the way on
time.sleep(0.01)
crickit.drive_1.fraction = 0.0 # all the way off
time.sleep(0.5)
else:
crickit.drive_1.fraction = 0.0

# button 2 electromagnet on
if not ss.digital_read(BUTTON_2):
print("Button 2 pressed")
crickit.drive_2.fraction = 1.0 # all the way on
time.sleep(0.5)
else:
crickit.drive_2.fraction = 0.0 # all the way off

# Capacitive touch + neopixel code
touch_raw_value = crickit.touch_1.raw_value

if touch_raw_value>800:
print("chase")
color_chase(PURPLE, 0.1)
else:
pixels.fill((0,0,0))
pixels.show()

# potentiomter + servo

# uncomment this line to see the values of the pot
# print((ss.analog_read(pot),))
# time.sleep(0.25)

# maps the range of the pot to the range of the servo
angle = map_range(ss.analog_read(pot), 0, 1023, 180, 0)

# sets the servo equal to the relative position on the pot
crickit.servo_1.angle = angle

# Light sensor + DC motor

# uncomment to see values of light
# print(light_in.value)
# time.sleep(0.5)

# reads the on-board light sensor and graphs the brighness with NeoPixels
# light value remaped to motor speed
peak = map_range(light_in.value, 3000, 62000, 0, 1)

# DC motor
crickit.dc_motor_1.throttle = peak # full speed forward

# hit both buttons to trigger noise
if not ss.digital_read(BUTTON_1) and not ss.digital_read(BUTTON_2):
print("Buttons 1 and 2 pressed")
for f in (262, 294, 330, 349, 392, 440, 494, 523):
tone(board.A0, f, 0.25)
time.sleep(SLEEP_DELAY)

Image 8 72064

Make sure the file saved to CIRCUITPY is named "code.py", this will allow it to run automatically when your CPX is powered on.

Test It Out

Go ahead and test out the code! What happens?

The following should occur:

  • Hit a button to trigger a solenoid
  • Hit a button to turn on an electromagnet
  • Touch conductive tape to trigger a NeoPixel animation
  • Turn a potentiometer to control a servo
  • Shine light on the CPX to trigger and change the speed of a DC motor
  • Hit both buttons to trigger a sound from the speaker!

Troubleshooting

Problem: I get an error in the REPL that says "map_range undefined"

Solution: Make sure simplio library is installed! Info on installing libraries here.

 

Problem: My Circuit Playground Express isn't recognized by Mu!

Solution: Make sure your board is set up with CircuitPython, which has the Circuit Playground Express show up as a flash drive named CIRCUITPY when you connect the CPX to your computer. If it is showing up as CPLAYBOOT on your computer, you can follow the steps in this guide to ensure CircuitPython is loaded and you see the CIRCUITPY drive.

 

Problem: My buttons don't work!

Solution: Make sure you've updated the CircuitPython firmware for CRICKIT from the CRICKIT guide.

 

Problem: Nothing is moving!

Solution: Check that your Circuit Playground Express is connected to a 5V power supply and the small slide switch on CRICKIT is set to "ON". Be sure the lightest servo wire faces away from the CRICKIT board, the darkest (black.brown) is closest to the center of CRICKIT.

 

Prepare the Box

Find yourself a large, flat box, with enough surface area to accommodate all the electronics you want to mount on it.

Image 9 71826

At this point, it's a good idea to lay out your electronics to get an idea for how they'll fit when mounted.

Some choices about where to arrange certain items must be made at this point, giving consideration to the placement of CRICKIT's various plugs and terminal blocks.

Image 10 71914

Sketch out placement of holes

Trace outlines of where you will need holes on cardboard box.

Image 11 71915

The holes cut in the box with make routing the cables to and from CRICKIT easy to organize.

Image 12 71916

For younger makers, we suggest having an older maker assist. All should be careful of sharp objects.

Cut out holes

Image 13 71929

Use something sharp (like a pen tip or tweezers) to poke holes.

Image 14 71930

Use a box cutter to cut out the larger rectangular holes.

Image 15 71931

Your box should now be ready to install CRICKIT and all its assorted electronics.

Image 16 71932

Making Connections

Buttons

Image 17 71828

Screw arcade buttons into holes in the box.

Image 18 71829

Image 19 71830

Connect the button terminals to CRICKIT's Signal port using male-to-male jumper wires plugged into the quick connect wires.

Image 20 71831

These buttons can be configured to control other things connected to CRICKIT, like the electromagnet and solenoid.

Image 21 72300

NeoPixel Strip

Image 22 71832

Feed the NeoPixel strip through hole in box.

Image 23 71833

Image 24 71834

Hold the strip in place with sections of double sided foam tape.

Image 25 71835

Capacitive Touch

Place a line of conductive tape on the box, leaving a small section at the end free to connect to an alligator clip.

Image 26 72034 

When touched, this capacitive strip can be used to trigger things such as NeoPixel animations.

Image 27 72323

Potentiometer

Image 28 72035

Install the potentiometer, screwing it tightly into place

Image 29 72036

Connect alligator clips to the terminals of the potentiometer inside the box.

Image 30 72037

Press the potentiometer knob into place.

Image 31 72038

Servo Motor

Press servo motor through rectangular hole, hold in place with a couple dabs of hot glue if necessary.

Image 32 72319

A protractor can make a fun addition as an angle indicator, or draw your own indicator directly on the box.

Image 33 72320

Cut an arrow out of paper and tape this to the servo arm, then press onto the servo horn.

Image 34 72321

The potentiometer in this example is connected to the servo motor, allowing the user to control the angle of the motor arm by turning the potentiometer knob.

Image 35 72324

 DC Motor

Image 36 72039

Screw the DC motor into place. If bolts aren't handy, a square of double-sided tape works just as well.

Image 37 72040

Affix a wheel to the hub of the motor.

Image 38 72041

For this project, the DC motor is used as a brightness indicator, increasing in speed in accordance with data received from the light sensor onboard Circuit Playground Express.

Image 39 72298

Solenoid

Use a small square of double sided foam tape to stick the solenoid to the box.

Image 40 72043

A bell taken from a generic hotel bell or bike bell works great when paired with this mini solenoid.

Image 41 72316

The solenoid can be triggered by a button press, and used to tap a bell or tuning fork to make it ring.

Image 42 72296

Electromagnet

Image 43 72045

Use a small piece of cardboard to hold the electromagnet perpendicular to the surface of the box.

Image 44 72046

Screw the wires coming out of the electromagnet into the Drive terminals on CRICKIT.

Image 45 72047

The electromagnet generates a magnetic field current is run through it, and loses its magnetism when the current is cut off. A nail or other sufficiently large piece of metal works well as an indicator for when the electromagnet is on or off.

Image 46 72297

Speaker

The small mono enclosed speaker can be stuck in place with double-sided tape, or connected with bolts to the box.

Image 47 72044

Pressing two buttons at once can perform a different function that either button on its own, like in this example, playing sound through the speaker.

Image 48 72325

Key Parts and Components

Add all Digi-Key Parts to Cart
  • 1528-2631-ND
  • 1528-2280-ND
  • 1528-2308-ND
  • 1528-2307-ND
  • 1528-1965-ND
  • 1528-1789-ND
  • 1528-1076-ND
  • 1528-2589-ND
  • 1528-2587-ND
  • 1528-2689-ND
  • 1528-2595-ND
  • 1528-2164-ND
  • 1528-2744-ND
  • 1528-1794-ND
  • 987-1309-ND