The Signals block on Crickit allows you to expand your general-purpose inputs and outputs (GPIO).
The Circuit Playground Express and Crickit combination is at left.
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!
MakeCode has three blocks under the CRICKIT group to help you work with signals:
crickit digital read signalallows you to read digital values in
crickit analog read signalreads a signal and provides an analog value from 0-1023
crickit digital write signalallows you to write out to a signal line
Analog read returns a number so the block is rounded to place where a number may be used. Digital read is angled so it fits where a decision like
if..then..else blocks use. Write signal is a block of its own and will set a signal (Make it
HIGH / 3.3 volts or
LOW / 0 volts).
Here is the MakeCode that reads the buttons on signal #1 and #2 and lights signal #3 and signal #4 if the corresponding button is pressed:
And here is the example code. You can see we read the signal with
crickit analog read signal which returns a value from 0 to 1023.
map MATH function changes 0 to 1023 to 0 to 9. The
graph NEOPIXEL block will light the number of NeoPixels
map returns in rainbow colors.
Be sure the potentiometer is connected to Crickit Signal 3 and not one of the other Signal terminals.
The code displays a
heart icon on the micro:bit display. The brightness is changed by taking the reading from the potentiometer connected to Crickit Signal 3 (0 to 1023) and dividing by 4 to get a
brightness from 0 to 255. So the potentiometer is essentially a manual brightness control for the micro:bit LED array.