What would make a relay even better? How about controlling a relay over the internet from anywhere in the world? Yea!
This process is made really simple using the Teleduino sketch for your ethernet enabled Arduino. Haven't heard of Teleduino? That's cool, you may want to take a look at Arduino Control via a Web Service with Teleduino to get yourself started.
This tutorial will guide you through the process of attaching a 5V relay to your Arduino, and provide some example Teleduino API calls to:
- Define the pin mode of a pin
- Turn on the relay
- Turn off the relay
- Toggle the relay
Let's get started!
Step 1: Parts Needed and Circuit Diagram
You need the following parts to complete this tutorial:
- Breadboard (optional, but makes prototyping much easier)
- 5V Relay (the relay in the image has had legs added so that it can be connected to a breadboard)
- 1K Resistor
- 1N4001 Diode
- 2N2222 Transistor
- Some hookup wire
Take a peak at the attached circuit diagram. It shows how the components needs to be connected. You may need to look at the datasheet for your relay to know which pins are used for the coil.
The additional image illustrates the pin layout of your 2N2222 transistor. This will help you understand what pin needs to connect to which part of the circuit.
Time to get this hooked up!