gaiboten
Published © MPL-2.0

Winding machine DC motor Automatic Stop relay

This is my test project Automatically Stop off DC motor or 220v motor via a relay

BeginnerFull instructions provided1,518
Winding machine DC motor Automatic Stop relay

Things used in this project

Hardware components

Reed Switch, Magnet Switch Set
Reed Switch, Magnet Switch Set
×1
Arduino UNO
Arduino UNO
×1
Geared DC Motor, 12 V
Geared DC Motor, 12 V
×1
Signal Relay, 5 VDC
Signal Relay, 5 VDC
×1
SparkFun 7-Segment Serial Display - Red
SparkFun 7-Segment Serial Display - Red
×1
Gravity:Digital Push Button (Yellow)
DFRobot Gravity:Digital Push Button (Yellow)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

winder_scheme_dc_motor_2_QkeyYJzrPH.jpg

Code

Winding machine code.ino

Arduino
///////////// PROJECT BY: GeoProgrammer
#include "SevSeg.h"
SevSeg sevseg;

int Button1 = A0;
int Button2 = A1;
int StartButton = A2;
int magnetsensor = A3;
int RELE = A4;
float Speed =370;
int SetNumber =0; 
boolean pauseNumber = false ;
boolean lock = false;
boolean magnetlock =true;
int magnetflag = 0;
void setup() {
    pinMode(Button1,INPUT_PULLUP);
    pinMode(Button2,INPUT_PULLUP);
     pinMode(magnetsensor,INPUT_PULLUP);
    pinMode(StartButton,INPUT_PULLUP);
     pinMode(RELE,OUTPUT);
  byte numDigits = 4;
  byte digitPins[] = {13, 10, 9, 2};
  byte segmentPins[] = {12, 8, 4, 6,7, 11, 3, 5};
  
  bool resistorsOnSegments = true; 
  byte hardwareConfig = COMMON_CATHODE; 
  bool updateWithDelays = false;
  bool leadingZeros = true;
  bool disableDecPoint = true;
  
  sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments,
  updateWithDelays, leadingZeros, disableDecPoint);
  sevseg.setBrightness(50);
      digitalWrite(RELE,HIGH);

}

void loop() {
  
    for (long i = 0; i <=  Speed; i++){
      sevseg.setNumber(SetNumber ,0);
      sevseg.refreshDisplay();
      }
  //-------------------------------------------------------------Knopka +

if (lock == false){

if(digitalRead(Button2)==LOW){
       Speed = 370;
           SetNumber ++;
          if(SetNumber  > 9999)
          SetNumber  = 0;
        } 
}  

//-----------------------------------------------------------------Knopka - 
            if (lock == false){
            if(digitalRead(Button1)==LOW){
           Speed = 370;
           SetNumber--;         
          if(SetNumber  < 0)
          SetNumber  =  0;
                    }
                       }

//-------------------------------------------------------------orive knopka ganuleba
  if (digitalRead(Button1)==LOW && digitalRead(Button2)==LOW ){
        Speed = 370;
        sevseg.blank();
        delay(350);
        magnetlock = true;
        lock = false; 
        SetNumber=0;
        digitalWrite(RELE,HIGH);
                }      
//----------------------------------------------------------------START Winding
 
 
 if(digitalRead(StartButton)==LOW){
    
  Speed=300;
   if(SetNumber  < 0){
    SetNumber  =  0;
     digitalWrite(RELE,HIGH);
                }
        
   if(SetNumber  > 0){
  lock = true; 
  magnetlock = false;
  sevseg.blank();
  delay(500);
   digitalWrite(RELE,LOW);
               }    
            }              
        
  //---------------------------------------------------------------------------Magnet
    if (magnetlock == false){
  if(digitalRead(magnetsensor)==LOW){

            if ( magnetflag ==0){
            Speed = 10;
            SetNumber--;         
            if (0==SetNumber){
             digitalWrite(RELE,HIGH);
            sevseg.blank();
            delay(350);
              lock = false;                  
                magnetlock = true;
                }
                              }
            magnetflag=1;
            }
            else if( magnetflag==1) {
               magnetflag =0;
            }
              }
       
} 

Credits

gaiboten

gaiboten

0 projects • 1 follower

Comments

Add projectSign up / Login