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
Post a Comment