Introduction: Controlling Devices Through Arduino With Mechanical Switching

Picture of 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.

Picture of 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.

Picture of 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

Picture of 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.

Picture of Mounting the Switch Continued.

The copper clad portion of the switch is mounted to the bicycle frame.

Step 5: Sample Code for Arduino

Picture of 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

Picture of 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

Picture of 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

Picture of Conclusion

By using an Arduino to control a relay, a simple mechanical switch can be used to control many different types of devices.

Comments

diy_bloke (author)2017-12-16

I am not quite sure why you would want to switch anything with yr bicycle as this is all wired, but making a switch from copper pipe might be a bit expensive, can I suggest a magnet and reed switch

About This Instructable

602views

19favorites

License:

More by _Ben:Controlling Devices Through Arduino With Mechanical SwitchingSqueaky Sneaks(fart Shoes)
Add instructable to: