Hackster is hosting Hackster Holidays, Ep. 4: Livestream & Giveaway Drawing. Start streaming on Wednesday!Stream Hackster Holidays, Ep. 4 on Wednesday!
Robotics EveryDay
Published © LGPL

DIY Relay | Make Relay From Servo Motor | Arduino Servo Moto

This relay is made using servo motor. I wanted to control a DC motor with a microcontroller but I didn't have a relay so I made one

BeginnerFull instructions provided4 hours76
DIY Relay | Make Relay From Servo Motor | Arduino Servo Moto

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Geared DC Motor, 12 V
Geared DC Motor, 12 V
×1
9V 1A Switching Wall Power Supply
9V 1A Switching Wall Power Supply
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Breadboard, 830 Tie Points
Breadboard, 830 Tie Points

Story

Read more

Custom parts and enclosures

Servo Motor With Metalic Link

Sketchfab still processing.

DC Motor To Be Controlled

Sketchfab still processing.

Schematics

Circuit Schematic With SPDT Relay

Circuit Schematic With Servo Motor

Code

Code To Control Servo Motor; Which Will Control DC Motor And Act as Relay

Arduino
#include <Servo.h>
int pre,curr = 90; // servo position angle
int i; 
Servo myservo; 

void setup() {
  myservo.attach(10);  // attaches the servo on pin 9 to the servo object
  Serial.begin(9600);
  myservo.write(curr);
}

void rotate(int angle){
  if(angle>curr){
    for(i=curr;i<angle;i++){
      myservo.write(i);
      delay(10);
    }
    curr = angle;
  }else if(angle<curr){
    for(i=curr;i>angle;i--){
      myservo.write(i);
      delay(10);
    }
    curr = angle;
  } 
}


void loop() {
    
    while (Serial.available() > 0) {
      char a = Serial.read();

      if (a =='w'){
        Serial.println("Contact");
        rotate(105);
        delay(150);
      }else if (a =='s'){
        Serial.println("No Contact");
        rotate(60);
        delay(150);
      }if (a =='m'){
        Serial.println("Stand By");
        rotate(85);
        delay(150);
      }
    }
}

Credits

Robotics EveryDay

Robotics EveryDay

3 projects • 9 followers

Comments