Introduction: Controlling Devices Through Arduino With Mechanical Switching
The Arduino can be used to control devices through the use of simple mechanical switches an relays.
Step 1: Summary of Scope.
This diagram simplifies in what order events will happen to control a device or devices with the Arduino through the use of mechanical switches and relays. The relays are used to complete circuits that are intentionally being broken but normally complete. Such as power to a device.
Step 2: Constructing a Switch.
I'm choosing to construct a switch, but most any type of switch can used. Mine is constructed from a copper clad circuit board material and a piece of copper tubing. There is a gap carved into the board to create two contacts that the copper tubing can be used to complete a circuit.
Step 3: Mounting the Switch
My switch is being mounted to a bicycle so the rotation of the wheel completes a circuit that the Arduino can read through its analog I/O. The tubing is mounted to the rim of the bicycle....
Step 4: Mounting the Switch Continued.
The copper clad portion of the switch is mounted to the bicycle frame.
Step 5: Sample Code for Arduino
This sample code uses analogRead and analogWrite commands to read a signal switch input from analog pin 0 and write out to a digital output 9 with the analogWrite command. No code is needed in the "void setup" when using analogRead and analogWrite commands. The signal output from pin 9 is used to control a relay that powers the chosen device.
Step 6: Controlling the Device
The power circuit for the device, that is controlled by the relay, is interrupted by creating a gap between the batteries with pieces of copper clad circuit board placed back to back with leads attached.
Step 7: Breaking the Circuit
Placing the circuit boards between the batteries breaks the power circuit supplied to the device allowing it to be controlled by the relay.
Step 8: Conclusion
By using an Arduino to control a relay, a simple mechanical switch can be used to control many different types of devices.