Instructables
Picture of Experiment 16: relay module on pcDuino

A relay is an electrically operated switch. Many relays use an electromagnet to operate a switching mechanism mechanically, but other operating principles are also used. Relays are used where it is necessary to control a circuit by a low-power signal (with complete electrical isolation between control and controlled circuits), or where several circuits must be controlled by one signal. The first relays were used in long distance telegraph circuits, repeating the signal coming in from one circuit and re-transmitting it to another. Relays were used extensively in telephone exchanges and early computers to perform logical operations.

 
Remove these adsRemove these ads by Signing Up

Step 1: Part list

Picture of Part list
motor shield.jpg

  1. 1* pcDuino kits
  2. 1*Relay module
  3. 1*DC Motor
  4. 1* button
  5. Some wires

Step 2: Diagram

Picture of Diagram

Step 3: Code

#include

#define Relay 13 int val = 0;

void setup(){ pinMode(Relay, OUTPUT); pinMode(12, INPUT); }

void loop(){ val = digitalRead(12); if(val==HIGH){ digitalWrite(Relay,HIGH); }else{ digitalWrite(Relay,LOW); }

}

russ_hensel3 months ago

Great but sort of overkill, this task could be acomplished by a 1 transistor circuit instead of one with thousands and thousands of them.