Importance of switches and relays

Did you know that you can control anything that needs power with a microcontroller? Using switches or relays in robots, also known as touch sensors, you have the ability to broaden the number of actions a robot can do. Using a relay and some sensors, you could get a robot arm to cut a sandwich with an electric knife!

Supplies

You will need the following for this tutorial. As an Amazon Associate, I earn from qualifying purchases.

Using a 2-terminal Switch

A switch is a device that when pressed, stays on until you turn it off. It requires a pull-up resistor, and this video gives a great explanation of what a pull-up resistor does. Wire the switch as shown in the below diagram. (Replace the button in the diagram with the switch.)

Pressing the switch will turn on the LED. If you want the microprocessor to read the state of the button, connect the yellow wire to a digital pin and use the digitalRead function.

Using a 3-terminal Button

Sometimes a switch or button will have 3 terminals, but it’s almost the same as the 2-terminal option. The only difference is you also have an option for the default state to be on instead of off:

  1. Common (C)–This is the same as the Ground (GND) pin for a 2-terminal switch
  2. Normally Open (NO)–This is the power pin, just like a normal button or switch that is off by default
  3. Normally Closed (NC)–This is the opposite of NO, a power pin that is normally closed or on by default

Using Relays in Robots

A relay is like a switch that’s activated by code instead of a manual press. Use the following diagram to see how to wire up relays in robots:

Relays in Robots

Conclusion

Now that you have an understanding of switches and relays in robots, you can activate any device with your microprocessor using any kind of sensor, such as an ultrasonic sensor or camera. This is one of the first steps on learning to automate jobs around your house or with a mobile robot!