SlideShare a Scribd company logo
Connect a motor, two push buttons and two LEDS to the Arduino as shown below. The fan
should operate as listed.
Begin with
int buttonPin1 = 2;
int buttonPin2 = 4;
int ledPinGreen = 11;
int ledPinRed = 6;
int motorPin = 9;
Please program in Arduino as the following:
1. Fan is started or stopped by pressing push button 1
When starting the fan, ramp up using 110ms delay from 0 to 4 volts (levels 0 to 200), fan
remains running at 4 volts.
When stopping the fan, slow down using the same values (110ms delay and level 200 to 0).
2. When operator presses the overload switch (button 2), fan starts working at full speed (255)
and the overload alarm is lit (red LED).
3. When the overload switch (button 2) is pressed again, fan returns to normal operation at 4
volts (level 200).
4. Pressing the overload button when the fan is not operating has no effect.
5. Anytime the fan is on, on/off indictor is lit, otherwise it is off.
Solution
const int buttonPin1 = 2;
const int buttonPin2 = 4;
const int ledPinGreen = 11;
const int ledPinRed = 6;
const int motorPin = 9
//state varibles
boolean B1_state = false; //button 1 state
boolean B2_state = false; //button 2 state
// function declaration
void motorRun_Stop(boolean);
void overload(boolean,boolean);
void setup()
{
Serial.begin(9600); // for debugging
pinMode(buttonPin1,INPUT); // declaring as input
digitalWrite(buttonPin1,HIGH); // activating the pullup resistor
pinMode(buttonPin2,INPUT); // declaring as input
digitalWrite(buttonPin1,HIGH); // activating the pullup resistor
pinMode(ledPinGreen,OUTPUT);
pinMode(ledPinRed,OUTPUT);
pinMode(motorPin, OUTPUT);
}
void loop()
{
if(digitalRead(buttonPin1)== 1)
{
B1_state != B1_state;
motorRun_Stop(B1_state);
}
else if(digitalRead(buttonPin2)== 1)
{
B2_state != B2_state;
overload();
}
else
{
}
}
void motorRun_Stop(boolean x)
{
byte wait = 0;
if(x == true )
{
Serial.println("Motor has Overloaded");
digitalWrite(ledPinGreen,HIGH);
for (int i = 0; i<200;i++)
{
analogWrite(motorPin,i);
wait = micros();
while((micros()-wait)>550);
}
}
else if(x == false)
{
for (int i = 200; i>0;i--)
{
analogWrite(motorPin,i);
wait = micros();
while((micros()-wait)>550);
}
Serial.println("Motor has Stoped");
digitalWrite(ledPinGreen,LOW);
}
else
{
}
}
void overload(boolean x,boolean y)
{
byte wait = 0;
if(x == true && y == true)
{
analogWrite(motorPin,255);
Serial.println("Motor has overloaded");
digitalWrite(ledPinRed,HIGH);
}
else if(x == true && y==false)
{
analogWrite(motorPin,200);
Serial.println("Motor has stopped Overloading");
digitalWrite(ledPinRed,LOW);
}
else
{
}
}

More Related Content

Similar to Connect a motor, two push buttons and two LEDS to the Arduino as sho.pdf

Mh7 eu um v.02
Mh7 eu um v.02Mh7 eu um v.02
Mh7 eu um v.02
Domotica daVinci
 
Tlk43 Controller
Tlk43 ControllerTlk43 Controller
Tlk43 Controller
Joseph
 
Anole Hot Runner Controller
Anole Hot Runner ControllerAnole Hot Runner Controller
Anole Hot Runner Controller
Anole Hot Runner
 
Kpnp pss user guide20170330
Kpnp pss user guide20170330Kpnp pss user guide20170330
Kpnp pss user guide20170330
Stephen (Jangkyu) Lee
 
LED Lighting Product Attachment
LED Lighting Product AttachmentLED Lighting Product Attachment
LED Lighting Product AttachmentUltra LEDs
 
Aeotec Multisensor 7 Manual
Aeotec Multisensor 7 ManualAeotec Multisensor 7 Manual
Aeotec Multisensor 7 Manual
Domotica daVinci
 
Air condition remote controller
Air condition remote controllerAir condition remote controller
Air condition remote controller
Neo Hsieh
 
Kjr 29 b (termostato alam. fan coil)
Kjr 29 b (termostato alam. fan coil)Kjr 29 b (termostato alam. fan coil)
Kjr 29 b (termostato alam. fan coil)
German Nava
 
Hitachi manual de aire acondicionad PRIMAIRY.pdf
Hitachi  manual de aire  acondicionad PRIMAIRY.pdfHitachi  manual de aire  acondicionad PRIMAIRY.pdf
Hitachi manual de aire acondicionad PRIMAIRY.pdf
juan903901
 
Tlk94 Controller
Tlk94 ControllerTlk94 Controller
Tlk94 Controller
Joseph
 
Adafruit arduino-lesson-15-dc-motor-reversing
Adafruit arduino-lesson-15-dc-motor-reversingAdafruit arduino-lesson-15-dc-motor-reversing
Adafruit arduino-lesson-15-dc-motor-reversing
ziwhanda
 
LaunchPad MSP 430
LaunchPad MSP 430LaunchPad MSP 430
LaunchPad MSP 430
DodgeWorthington1
 
Wall Controller 4 Buttons rechargeable Remote Z-Wave Plus - Hank manual
Wall Controller	4 Buttons rechargeable Remote Z-Wave Plus - Hank manualWall Controller	4 Buttons rechargeable Remote Z-Wave Plus - Hank manual
Wall Controller 4 Buttons rechargeable Remote Z-Wave Plus - Hank manual
Domotica daVinci
 
Siemens room stat instructions
Siemens room stat instructionsSiemens room stat instructions
Siemens room stat instructions
Maria Isabel
 
Siemens room stat instructions
Siemens room stat instructionsSiemens room stat instructions
Siemens room stat instructions
Maria Isabel
 
Manual of Thermostat Fan Coil 4Pipes MH8 series - MCO HOME
Manual of Thermostat Fan Coil 4Pipes MH8 series - MCO HOME Manual of Thermostat Fan Coil 4Pipes MH8 series - MCO HOME
Manual of Thermostat Fan Coil 4Pipes MH8 series - MCO HOME
Domotica daVinci
 

Similar to Connect a motor, two push buttons and two LEDS to the Arduino as sho.pdf (20)

85 0065-e deluxe-installation insert_web
85 0065-e deluxe-installation insert_web85 0065-e deluxe-installation insert_web
85 0065-e deluxe-installation insert_web
 
Mh7 eu um v.02
Mh7 eu um v.02Mh7 eu um v.02
Mh7 eu um v.02
 
Tlk43 Controller
Tlk43 ControllerTlk43 Controller
Tlk43 Controller
 
85 0067-b5 outdoor-installation insert_web
85 0067-b5 outdoor-installation insert_web85 0067-b5 outdoor-installation insert_web
85 0067-b5 outdoor-installation insert_web
 
Anole Hot Runner Controller
Anole Hot Runner ControllerAnole Hot Runner Controller
Anole Hot Runner Controller
 
Cti troublshooting
Cti troublshootingCti troublshooting
Cti troublshooting
 
Kpnp pss user guide20170330
Kpnp pss user guide20170330Kpnp pss user guide20170330
Kpnp pss user guide20170330
 
LED Lighting Product Attachment
LED Lighting Product AttachmentLED Lighting Product Attachment
LED Lighting Product Attachment
 
Aeotec Multisensor 7 Manual
Aeotec Multisensor 7 ManualAeotec Multisensor 7 Manual
Aeotec Multisensor 7 Manual
 
85 0066-e ultimate-installation insert_web
85 0066-e ultimate-installation insert_web85 0066-e ultimate-installation insert_web
85 0066-e ultimate-installation insert_web
 
Air condition remote controller
Air condition remote controllerAir condition remote controller
Air condition remote controller
 
Kjr 29 b (termostato alam. fan coil)
Kjr 29 b (termostato alam. fan coil)Kjr 29 b (termostato alam. fan coil)
Kjr 29 b (termostato alam. fan coil)
 
Hitachi manual de aire acondicionad PRIMAIRY.pdf
Hitachi  manual de aire  acondicionad PRIMAIRY.pdfHitachi  manual de aire  acondicionad PRIMAIRY.pdf
Hitachi manual de aire acondicionad PRIMAIRY.pdf
 
Tlk94 Controller
Tlk94 ControllerTlk94 Controller
Tlk94 Controller
 
Adafruit arduino-lesson-15-dc-motor-reversing
Adafruit arduino-lesson-15-dc-motor-reversingAdafruit arduino-lesson-15-dc-motor-reversing
Adafruit arduino-lesson-15-dc-motor-reversing
 
LaunchPad MSP 430
LaunchPad MSP 430LaunchPad MSP 430
LaunchPad MSP 430
 
Wall Controller 4 Buttons rechargeable Remote Z-Wave Plus - Hank manual
Wall Controller	4 Buttons rechargeable Remote Z-Wave Plus - Hank manualWall Controller	4 Buttons rechargeable Remote Z-Wave Plus - Hank manual
Wall Controller 4 Buttons rechargeable Remote Z-Wave Plus - Hank manual
 
Siemens room stat instructions
Siemens room stat instructionsSiemens room stat instructions
Siemens room stat instructions
 
Siemens room stat instructions
Siemens room stat instructionsSiemens room stat instructions
Siemens room stat instructions
 
Manual of Thermostat Fan Coil 4Pipes MH8 series - MCO HOME
Manual of Thermostat Fan Coil 4Pipes MH8 series - MCO HOME Manual of Thermostat Fan Coil 4Pipes MH8 series - MCO HOME
Manual of Thermostat Fan Coil 4Pipes MH8 series - MCO HOME
 

More from amrishinda

JAVA A double-ended queue is a list that allows the addition and.pdf
JAVA A double-ended queue is a list that allows the addition and.pdfJAVA A double-ended queue is a list that allows the addition and.pdf
JAVA A double-ended queue is a list that allows the addition and.pdf
amrishinda
 
Let f(z) be an entire function such that fn+1(z) equivalent 0, Prove.pdf
Let f(z) be an entire function such that fn+1(z) equivalent 0, Prove.pdfLet f(z) be an entire function such that fn+1(z) equivalent 0, Prove.pdf
Let f(z) be an entire function such that fn+1(z) equivalent 0, Prove.pdf
amrishinda
 
Implement threads and a GUI interface using advanced Java Swing clas.pdf
Implement threads and a GUI interface using advanced Java Swing clas.pdfImplement threads and a GUI interface using advanced Java Swing clas.pdf
Implement threads and a GUI interface using advanced Java Swing clas.pdf
amrishinda
 
If a cells contents are greatly hypo-osmotic to the surrounding env.pdf
If a cells contents are greatly hypo-osmotic to the surrounding env.pdfIf a cells contents are greatly hypo-osmotic to the surrounding env.pdf
If a cells contents are greatly hypo-osmotic to the surrounding env.pdf
amrishinda
 
How are the forelimbs of humans, the wings of birds, the wings of ba.pdf
How are the forelimbs of humans, the wings of birds, the wings of ba.pdfHow are the forelimbs of humans, the wings of birds, the wings of ba.pdf
How are the forelimbs of humans, the wings of birds, the wings of ba.pdf
amrishinda
 
Fom 1120, Sched Mark for follow up Question 15 of 105. A corporat.pdf
Fom 1120, Sched Mark for follow up Question 15 of 105. A corporat.pdfFom 1120, Sched Mark for follow up Question 15 of 105. A corporat.pdf
Fom 1120, Sched Mark for follow up Question 15 of 105. A corporat.pdf
amrishinda
 
Germ cells are set aside during animal development and give rise to .pdf
Germ cells are set aside during animal development and give rise to .pdfGerm cells are set aside during animal development and give rise to .pdf
Germ cells are set aside during animal development and give rise to .pdf
amrishinda
 
Determine the missing amounts. (Hint For example, to solve for (a), .pdf
Determine the missing amounts. (Hint For example, to solve for (a), .pdfDetermine the missing amounts. (Hint For example, to solve for (a), .pdf
Determine the missing amounts. (Hint For example, to solve for (a), .pdf
amrishinda
 
Discuss the various methods of intellectual property protection avai.pdf
Discuss the various methods of intellectual property protection avai.pdfDiscuss the various methods of intellectual property protection avai.pdf
Discuss the various methods of intellectual property protection avai.pdf
amrishinda
 
devise a hypothesis that explains the geographical distribution of m.pdf
devise a hypothesis that explains the geographical distribution of m.pdfdevise a hypothesis that explains the geographical distribution of m.pdf
devise a hypothesis that explains the geographical distribution of m.pdf
amrishinda
 
Describe a diode array detector and CCD camera. Differentiate betwee.pdf
Describe a diode array detector and CCD camera. Differentiate betwee.pdfDescribe a diode array detector and CCD camera. Differentiate betwee.pdf
Describe a diode array detector and CCD camera. Differentiate betwee.pdf
amrishinda
 
Consider managers (supervisors) that you have worked for in the past.pdf
Consider managers (supervisors) that you have worked for in the past.pdfConsider managers (supervisors) that you have worked for in the past.pdf
Consider managers (supervisors) that you have worked for in the past.pdf
amrishinda
 
Caterpillar is one of the Americas major exporters. The company sell.pdf
Caterpillar is one of the Americas major exporters. The company sell.pdfCaterpillar is one of the Americas major exporters. The company sell.pdf
Caterpillar is one of the Americas major exporters. The company sell.pdf
amrishinda
 
what numbers go with these descriptions.1. Uses ATP hydrolysis2..pdf
what numbers go with these descriptions.1. Uses ATP hydrolysis2..pdfwhat numbers go with these descriptions.1. Uses ATP hydrolysis2..pdf
what numbers go with these descriptions.1. Uses ATP hydrolysis2..pdf
amrishinda
 
What are the three forms of Business Organizations Answer the follow.pdf
What are the three forms of Business Organizations Answer the follow.pdfWhat are the three forms of Business Organizations Answer the follow.pdf
What are the three forms of Business Organizations Answer the follow.pdf
amrishinda
 
Anatomy Question Use your own words.A girl with a defective heart.pdf
Anatomy Question Use your own words.A girl with a defective heart.pdfAnatomy Question Use your own words.A girl with a defective heart.pdf
Anatomy Question Use your own words.A girl with a defective heart.pdf
amrishinda
 
Why parkinsons disease is special among the different neurological.pdf
Why parkinsons disease is special among the different neurological.pdfWhy parkinsons disease is special among the different neurological.pdf
Why parkinsons disease is special among the different neurological.pdf
amrishinda
 
Which statement is not true promoters are transcribed the Pribnow .pdf
Which statement is not true  promoters are transcribed  the Pribnow .pdfWhich statement is not true  promoters are transcribed  the Pribnow .pdf
Which statement is not true promoters are transcribed the Pribnow .pdf
amrishinda
 
When extracting DNA of an fruit how does the environemnt (how hot or.pdf
When extracting DNA of an fruit how does the environemnt (how hot or.pdfWhen extracting DNA of an fruit how does the environemnt (how hot or.pdf
When extracting DNA of an fruit how does the environemnt (how hot or.pdf
amrishinda
 
Which ANN do you prefer amidst of the variety of ANNs Justify the r.pdf
Which ANN do you prefer amidst of the variety of ANNs Justify the r.pdfWhich ANN do you prefer amidst of the variety of ANNs Justify the r.pdf
Which ANN do you prefer amidst of the variety of ANNs Justify the r.pdf
amrishinda
 

More from amrishinda (20)

JAVA A double-ended queue is a list that allows the addition and.pdf
JAVA A double-ended queue is a list that allows the addition and.pdfJAVA A double-ended queue is a list that allows the addition and.pdf
JAVA A double-ended queue is a list that allows the addition and.pdf
 
Let f(z) be an entire function such that fn+1(z) equivalent 0, Prove.pdf
Let f(z) be an entire function such that fn+1(z) equivalent 0, Prove.pdfLet f(z) be an entire function such that fn+1(z) equivalent 0, Prove.pdf
Let f(z) be an entire function such that fn+1(z) equivalent 0, Prove.pdf
 
Implement threads and a GUI interface using advanced Java Swing clas.pdf
Implement threads and a GUI interface using advanced Java Swing clas.pdfImplement threads and a GUI interface using advanced Java Swing clas.pdf
Implement threads and a GUI interface using advanced Java Swing clas.pdf
 
If a cells contents are greatly hypo-osmotic to the surrounding env.pdf
If a cells contents are greatly hypo-osmotic to the surrounding env.pdfIf a cells contents are greatly hypo-osmotic to the surrounding env.pdf
If a cells contents are greatly hypo-osmotic to the surrounding env.pdf
 
How are the forelimbs of humans, the wings of birds, the wings of ba.pdf
How are the forelimbs of humans, the wings of birds, the wings of ba.pdfHow are the forelimbs of humans, the wings of birds, the wings of ba.pdf
How are the forelimbs of humans, the wings of birds, the wings of ba.pdf
 
Fom 1120, Sched Mark for follow up Question 15 of 105. A corporat.pdf
Fom 1120, Sched Mark for follow up Question 15 of 105. A corporat.pdfFom 1120, Sched Mark for follow up Question 15 of 105. A corporat.pdf
Fom 1120, Sched Mark for follow up Question 15 of 105. A corporat.pdf
 
Germ cells are set aside during animal development and give rise to .pdf
Germ cells are set aside during animal development and give rise to .pdfGerm cells are set aside during animal development and give rise to .pdf
Germ cells are set aside during animal development and give rise to .pdf
 
Determine the missing amounts. (Hint For example, to solve for (a), .pdf
Determine the missing amounts. (Hint For example, to solve for (a), .pdfDetermine the missing amounts. (Hint For example, to solve for (a), .pdf
Determine the missing amounts. (Hint For example, to solve for (a), .pdf
 
Discuss the various methods of intellectual property protection avai.pdf
Discuss the various methods of intellectual property protection avai.pdfDiscuss the various methods of intellectual property protection avai.pdf
Discuss the various methods of intellectual property protection avai.pdf
 
devise a hypothesis that explains the geographical distribution of m.pdf
devise a hypothesis that explains the geographical distribution of m.pdfdevise a hypothesis that explains the geographical distribution of m.pdf
devise a hypothesis that explains the geographical distribution of m.pdf
 
Describe a diode array detector and CCD camera. Differentiate betwee.pdf
Describe a diode array detector and CCD camera. Differentiate betwee.pdfDescribe a diode array detector and CCD camera. Differentiate betwee.pdf
Describe a diode array detector and CCD camera. Differentiate betwee.pdf
 
Consider managers (supervisors) that you have worked for in the past.pdf
Consider managers (supervisors) that you have worked for in the past.pdfConsider managers (supervisors) that you have worked for in the past.pdf
Consider managers (supervisors) that you have worked for in the past.pdf
 
Caterpillar is one of the Americas major exporters. The company sell.pdf
Caterpillar is one of the Americas major exporters. The company sell.pdfCaterpillar is one of the Americas major exporters. The company sell.pdf
Caterpillar is one of the Americas major exporters. The company sell.pdf
 
what numbers go with these descriptions.1. Uses ATP hydrolysis2..pdf
what numbers go with these descriptions.1. Uses ATP hydrolysis2..pdfwhat numbers go with these descriptions.1. Uses ATP hydrolysis2..pdf
what numbers go with these descriptions.1. Uses ATP hydrolysis2..pdf
 
What are the three forms of Business Organizations Answer the follow.pdf
What are the three forms of Business Organizations Answer the follow.pdfWhat are the three forms of Business Organizations Answer the follow.pdf
What are the three forms of Business Organizations Answer the follow.pdf
 
Anatomy Question Use your own words.A girl with a defective heart.pdf
Anatomy Question Use your own words.A girl with a defective heart.pdfAnatomy Question Use your own words.A girl with a defective heart.pdf
Anatomy Question Use your own words.A girl with a defective heart.pdf
 
Why parkinsons disease is special among the different neurological.pdf
Why parkinsons disease is special among the different neurological.pdfWhy parkinsons disease is special among the different neurological.pdf
Why parkinsons disease is special among the different neurological.pdf
 
Which statement is not true promoters are transcribed the Pribnow .pdf
Which statement is not true  promoters are transcribed  the Pribnow .pdfWhich statement is not true  promoters are transcribed  the Pribnow .pdf
Which statement is not true promoters are transcribed the Pribnow .pdf
 
When extracting DNA of an fruit how does the environemnt (how hot or.pdf
When extracting DNA of an fruit how does the environemnt (how hot or.pdfWhen extracting DNA of an fruit how does the environemnt (how hot or.pdf
When extracting DNA of an fruit how does the environemnt (how hot or.pdf
 
Which ANN do you prefer amidst of the variety of ANNs Justify the r.pdf
Which ANN do you prefer amidst of the variety of ANNs Justify the r.pdfWhich ANN do you prefer amidst of the variety of ANNs Justify the r.pdf
Which ANN do you prefer amidst of the variety of ANNs Justify the r.pdf
 

Recently uploaded

CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 

Recently uploaded (20)

CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 

Connect a motor, two push buttons and two LEDS to the Arduino as sho.pdf

  • 1. Connect a motor, two push buttons and two LEDS to the Arduino as shown below. The fan should operate as listed. Begin with int buttonPin1 = 2; int buttonPin2 = 4; int ledPinGreen = 11; int ledPinRed = 6; int motorPin = 9; Please program in Arduino as the following: 1. Fan is started or stopped by pressing push button 1 When starting the fan, ramp up using 110ms delay from 0 to 4 volts (levels 0 to 200), fan remains running at 4 volts. When stopping the fan, slow down using the same values (110ms delay and level 200 to 0). 2. When operator presses the overload switch (button 2), fan starts working at full speed (255) and the overload alarm is lit (red LED). 3. When the overload switch (button 2) is pressed again, fan returns to normal operation at 4 volts (level 200). 4. Pressing the overload button when the fan is not operating has no effect. 5. Anytime the fan is on, on/off indictor is lit, otherwise it is off. Solution const int buttonPin1 = 2; const int buttonPin2 = 4; const int ledPinGreen = 11; const int ledPinRed = 6; const int motorPin = 9 //state varibles boolean B1_state = false; //button 1 state boolean B2_state = false; //button 2 state // function declaration void motorRun_Stop(boolean); void overload(boolean,boolean); void setup()
  • 2. { Serial.begin(9600); // for debugging pinMode(buttonPin1,INPUT); // declaring as input digitalWrite(buttonPin1,HIGH); // activating the pullup resistor pinMode(buttonPin2,INPUT); // declaring as input digitalWrite(buttonPin1,HIGH); // activating the pullup resistor pinMode(ledPinGreen,OUTPUT); pinMode(ledPinRed,OUTPUT); pinMode(motorPin, OUTPUT); } void loop() { if(digitalRead(buttonPin1)== 1) { B1_state != B1_state; motorRun_Stop(B1_state); } else if(digitalRead(buttonPin2)== 1) { B2_state != B2_state; overload(); } else { } } void motorRun_Stop(boolean x) { byte wait = 0; if(x == true ) { Serial.println("Motor has Overloaded"); digitalWrite(ledPinGreen,HIGH); for (int i = 0; i<200;i++) { analogWrite(motorPin,i);
  • 3. wait = micros(); while((micros()-wait)>550); } } else if(x == false) { for (int i = 200; i>0;i--) { analogWrite(motorPin,i); wait = micros(); while((micros()-wait)>550); } Serial.println("Motor has Stoped"); digitalWrite(ledPinGreen,LOW); } else { } } void overload(boolean x,boolean y) { byte wait = 0; if(x == true && y == true) { analogWrite(motorPin,255); Serial.println("Motor has overloaded"); digitalWrite(ledPinRed,HIGH); } else if(x == true && y==false) { analogWrite(motorPin,200); Serial.println("Motor has stopped Overloading"); digitalWrite(ledPinRed,LOW); }