Download our “Getting Started” guide, which includes an overview of the Crumble software and a step-by-step guide to writing your first program. It also covers:
- Sparkle control
- Motor control
- Using inputs (digital and analogue)
- Using variables and maths in your programs
Crumble: other i/o devices
An example of a digital input is our crumble-friendly switch (either on or off), while an analogue input (e.g. an LDR) gives a variable voltage depending on external conditions (in this case, light). While you can connect many standard electronic inputs and outputs (LEDs, switches, buzzers etc.) to your Crumble, we sell several more “crumble friendly” components in our shop, including:
Servos
The servo receives power through its “+” and “-” pads and data through pad “S”. “S” needs to be connected to either A, B, C or D on the Crumble (it doesn’t matter which; in fact, you can connect and control 4 servos at once). In the Crumble software, the servo control block is used to set the position of the servo arm. Note: this is an absolute, rather than a relative angle, in degrees, so you might need to experiment to get the range of movement you want. This block, for example, sets a servo connected to output “C” on the Crumble to 90 degrees:
An example project, using a servo, is described here.
Note: Prior to version 1.0.13, the servo only holds its position whilst the program is running – it stops when the program ends. Use wait statements or a do forever loop to keep it holding its position.
Ultrasonic Distance Sensors
The ultrasonic distance sensor times the echo of a high frequency pulse of sound to give a distance (in centimetres) to an object. It requires power, through its “+” and “-” pads, and two signal connections, “E” and “T” (echo and trigger).
The block in the software which receives data from the distance sensor is:
Here, A and B tell the Crumble which pads the trigger (T) and echo (E) are connected to. The rounded shape of the ultrasonic block indicates that it represents a variable (the distance an object is from the sensor). The Crumble can monitor this variable in real time and display its value under the “Variables” menu. In the example below, the ultrasonic distance sensor has detected an object 12cm away.
The variable, t, can then be used in an “if” block to control other outputs. For example, to stop a buggy crashing into a wall or to flash a light if something approaches.
Line following module
These have optical reflective sensors at each end which contain an IR LED and a phototransistor.
There are 4 pads: “+” and “-” connect to power, while “R” and “L” (right and left) connect to two of pads A, B, C and D on the Crumble. The program below assumes “R” on the line-follower board is connected to “B” and “L” is connected to “C”.
There is more information about writing programs to use the line-following module here.