0% found this document useful (0 votes)
29 views3 pages

Code

Uploaded by

waseemkhan192003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views3 pages

Code

Uploaded by

waseemkhan192003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include <LiquidCrystal.

h>
LiquidCrystal lcd(7,6, 5, 4, 3, 2);
#define sw1 14
#define sw2 15
#define sw3 16
#define sw4 17
unsigned int a=0;
unsigned int b,c,p,q;

void setup()
{
pinMode(sw1, INPUT);
pinMode(sw2, INPUT);
pinMode(sw3, INPUT);
pinMode(sw4, INPUT);
analogWrite(9, 0);
analogWrite(10, 0);
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print(" Four Quadrant ");
lcd.setCursor(0,1);
lcd.print("DC Motor Control");
delay(2000);
lcd.clear();
}

void loop()
{
if (digitalRead(17)==LOW && a==0)
{
a=1;
b=0;
lcd.setCursor(0,0);
lcd.print("Stop ");
delay(1000);
analogWrite(9, 0);
analogWrite(10, 0);

}
else if (digitalRead(17)==LOW && b==0)
{
b=1;
c=0;
p=0;
lcd.setCursor(0,0);
lcd.print("Clockwise......");
delay(1000);
}
else if (digitalRead(17)==LOW && c==0)
{
c=1;
a=0;
q=0;
p=1;

lcd.setCursor(0,0);
lcd.print("Anti-clockwise...");
delay(1000);
}
else if (digitalRead(14)==LOW && p==0)
{
lcd.setCursor(0,0);
lcd.print("Speed: 25% C ");
analogWrite(9, 70);
analogWrite(10, 0);
}
else if (digitalRead(15)==LOW && p==0)
{
lcd.setCursor(0,0);
lcd.print("Speed: 65% C ");

analogWrite(9, 150);
analogWrite(10, 0);
}
else if (digitalRead(16)==LOW && p==0)
{
lcd.setCursor(0,0);
lcd.print("Speed: 100% C ");

analogWrite(9, 255);
analogWrite(10, 0);

else if (digitalRead(14)==LOW && q==0)


{
lcd.setCursor(0,0);
lcd.print("Speed: 25% AC ");
analogWrite(9, 0);
analogWrite(10, 70);
}
else if (digitalRead(15)==LOW && q==0)
{
lcd.setCursor(0,0);
lcd.print("Speed: 65% AC ");

analogWrite(9, 0);
analogWrite(10, 150);
}
else if (digitalRead(16)==LOW && q==0)
{
lcd.setCursor(0,0);
lcd.print("Speed: 100% AC ");

analogWrite(9, 0);
analogWrite(10, 255);

}
}

You might also like