Although the outputs (motors, Sparkles, buzzers etc) of the Crumble get a lot of love and attention, we mustn’t forget how awesome inputs are! They allow us to interact with our projects. Arguably the simplest type of input, the humble switch provides us with a digital(binary) input for the Crumble; it is either on/off or HI/LO.
Before we look at making our own switch, we need to consider what a switch is, and what it does. This will help us later on. If you already have a good understanding, then feel free to skip over the next bit.
First, let us consider a circuit – a closed loop of conductive material and electronic components through which electricity flows. The important word here is ‘closed’. Electricity will only flow when there is a clear path from positive (+ve) to negative (-ve). If we break the circuit/connection, then the electricity will stop flowing. This can be very useful when we want to control components in a circuit e.g. a buzzer or a light. We can do this by using a switch – a component which we use to control the flow of electricity.
There are all manner of switches available, from a good ol’ push switch to an illuminated key switch. But sometimes there just isn’t quite the one we want, or one we can integrate into a project how we want. A great way of solving a particular problem and thinking about how switches work is to make your own. To make something, which when interacted with in some way, will close a circuit. Not only does this give you a great insight as to how switches work, the concepts involved are perfect for meeting various Computing/Science/Design & Technology curriculum targets.
So without further ado, let us look at different ways to make switches!
First of all, let’s make a classic split pin/paperclip switch.
By moving the paperclip, we can open/close the switch. The paperclip joins together our two contacts (split pins), which are connected to the Crumble – one on a +ve output, and the other to an input (A, B or C – D is used for a Sparkle). When the connection is made, A becomes HI and the Crumble turns a Sparkle on red. When the connection is broken, the Sparkle turns off.
Our code for this is as follows. Although not the most efficient way of achieving our desired result, this code is easily extendable for our rotary switch. If A is HI, then set the Sparkle red, otherwise turn the sparkle off.
Continuing along the theme of a simple switch, lets make a ‘pressure pad’ style switch.
When pressure is applied to the top surface, the foil bridges the gap between the two foil contacts on the bottom surface (connected to the Crumble as before). This then runs the same program as before – the switch is a straight swap.
Finally, we decided that we wanted a rotary switch, with multiple outputs.
The centre arrow can be lined up with one of three outputs. Each one connects to a separate input on the Crumble. Depending on which one of the inputs is HI, the Crumble lights the Sparkle red, green or blue.
The code for this is an extension of our previous two switches, except that we check for multiple different conditions being true (inputs being HI).
These are just a few different ways of making your own switch. By taking the very basic principle of ‘bridging a gap’ and closing a circuit, you can easily let your creativity run.