Proteus Simulation 1 Button Motor control with Arduino and N channel Mosfet

 



int pbutton=8;//Initialised pin # 8 as variable name pushtton
int Motor=3;//initialised pin # 3 as Motor

int val=0;// at initial value of variable name val = 0
int Motor_on=0;//at initial value of variable name Motor_on = 0
int pushed=0;//at initial value of variable name pushed = 0

void setup()
{
  Serial.begin(9600);
  pinMode(pbutton, INPUT_PULLUP);// Connect one point of Pushbutton to D8 Pin of Arduino and other point to GND of Arduino.
  
  pinMode(Motor, OUTPUT);
}

void loop() 
{
  val=digitalRead(pbutton);
  if(val==HIGH && Motor_on==LOW)
  {
    pushed=1-pushed;
    delay(100);
  }

  Motor_on=val;
  if(pushed==LOW)
  {
    Serial.println("Motor is Running");
    digitalWrite(Motor,HIGH);
  }
  
  else
  {
    Serial.println("Motor is Stopped");
    digitalWrite(Motor, LOW);
  }
}


Comments

Popular posts from this blog

4 Stage Timer With DS3231RTC Module.

Interfacing KY038 sound sensor with Raspberry pi Pico

Interfacing MQ2 Gas & Smoke Sensor With Raspberry Pi Pico