Connecting various sensors, switches, and indicators is easy with Crickit.

The Crickit with Circuit Playground Express is shown at the left.

Note that external pull up (or pull down) resistors are needed on the Crickit Signals block as Seesaw does not have the capability to set internal pull up or pull down resistors like on direct microcontrollers.

Connections to a Crickit with Feather board are identical.

Note that if you plan to use CircuitPython, the Feather board you choose should be one that is supported by CircuitPython (there are a few Feathers that cannot be programmed with CircuitPython).

The Signals block on the Crickit HAT for Raspberry Pi gives you 8 bidirectional general purpose input/output (GPIO) (analog/digital) ports.

Since the Crickit HAT takes pins away from the Raspberry pi to control everything, the Signals block helps to provide some pins back and they all can accept analog input too (unlike RasPi pins).

You may want to add buttons, LEDs, switches or simple sensors to your robot project. With Crickit, you get 8 x 'general purpose in/out' (GPIO) pins called signals. Each signal can be a digital input (button/switch), digital output (LED, for example), or analog input.

This lets you add a ton of external components easily, and its all handled by seesaw. Perfect when you have a Feather without analog inputs (like the ESP8266) or just need a ton of extra pins.

The signal pins are on a 3x8 female header, so you can poke wires directly in!

Here's an example wiring that goes with the code below.

We have two switch buttons, connected to signals #1 and #2, the other side of the buttons connect to ground

There's also two LEDs, connected to the signals #3 and #4 and the negative wires connected to ground. (All the 3.3V and Ground pins are connected together so you don't have to use the ones right next to the signal pin!)

import time
from adafruit_crickit import crickit

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

# Two buttons are pullups, connect to ground to activate
BUTTON_1 = crickit.SIGNAL1  # button #1 connected to signal port 1 & ground
BUTTON_2 = crickit.SIGNAL2  # button #2 connected to signal port 2 & ground

# Two LEDs are outputs, on by default
LED_1 = crickit.SIGNAL3    # LED #1 connected to signal port 3 & ground
LED_2 = crickit.SIGNAL4    # LED #2 connected to signal port 4 & ground

ss.pin_mode(LED_1, ss.OUTPUT)
ss.pin_mode(LED_2, ss.OUTPUT)
ss.pin_mode(BUTTON_1, ss.INPUT_PULLUP)
ss.pin_mode(BUTTON_2, ss.INPUT_PULLUP)
ss.digital_write(LED_1, True)
ss.digital_write(LED_2, True)

while True:
    if not ss.digital_read(BUTTON_1):
        print("Button 1 pressed")
        ss.digital_write(LED_1, True)
    else:
        ss.digital_write(LED_1, False)

    if not ss.digital_read(BUTTON_2):
        print("Button 2 pressed")
        ss.digital_write(LED_2, True)
    else:
        ss.digital_write(LED_2, False)

Each of the 8 signal pin numbers is available under the crickit object as SIGNAL1 through SIGNAL8. Note these are not DigitalInOut or Pin objects! We need to use the crickit.seesaw object to set the mode, direction, and readings

To simplify our code we shorted the crickit.seesaw object to just ss

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

Digital Pin Modes

You can set the mode of each signal pin with ss.pin_mode(signal, mode) where signal is the crickit.SIGNAL# from above and mode can be ss.OUTPUT, ss.INPUT or ss.INPUT_PULLUP.

ss.pin_mode(BUTTON_1, ss.INPUT_PULLUP)
ss.pin_mode(BUTTON_2, ss.INPUT_PullUP)
...
ss.pin_mode(LED_1, ss.OUTPUT)
ss.pin_mode(LED_2, ss.OUTPUT)

Digital Read

Then, you can read the values True or False with ss.digital_read(signal)

Don't forget you have to set it to be an INPUT first! And if you don't have an external pull up resistor, you'll need to set it in the code.

ss.digital_read(BUTTON_1)

Digital Write

Or, you can set the signal you want to a high value with ss.digital_write(signal, True), or set to low value with ss.digital_write(signal, False). Don't forget you have to set it to be an OUTPUT first!

# LED On
ss.digital_write(LED_2, True)
# LED Off
ss.digital_write(LED_2, False)

Analog Reads

You can also read analog values like from a potentiometer or sensor.

 

Let's do a demonstration where the center tap of a potentiometer is hooked up to Signal #3 - don't forget to also connect one side of the potentiometer to 3.3V and the other side to ground.

And here is the example code. You can see we read the signal with ss.analog_read(signal) which returns a value from 0 to 1023.

import time
from adafruit_crickit import crickit

# For signal control, we'll chat directly with seesaw, use 'ss' to shorted typing!
ss = crickit.seesaw
# potentiometer connected to signal #3
pot = crickit.SIGNAL3

while True:
    print((ss.analog_read(pot),))
    time.sleep(0.25)

By printing the value in a python tuple (ss.analog_read(pot),) we can use the Mu plotter to see the values immediately!

This guide was first published on Dec 14, 2018. It was last updated on Oct 24, 2023.

This page (CircuitPython Signals) was last updated on Oct 24, 2023.

Text editor powered by tinymce.