The clickers lib
Dependents: ROCO104_Buggy BuggyDesign
clickers.cpp
00001 #include "mbed.h" 00002 #include "motor.h" 00003 #include "clickers.h" 00004 #include "UltraSonic.h" 00005 00006 //These externs allow variables and functiones to be used that in another folder/library 00007 extern DigitalIn microswitch1; //Instance of the DigitalIn class called 'microswitch1' 00008 extern DigitalIn microswitch2; //Instance of the DigitalIn class called 'microswitch2' 00009 extern Motor Wheel; 00010 extern Serial pc; 00011 extern int mm; 00012 extern void dist(); 00013 extern bool rStopped, fStopped; 00014 00015 void RevStop()//This function will stop the buggy and change the bool to true to say the buggy has been stopped from going backwards 00016 { 00017 if (microswitch1 == true) 00018 { 00019 microswitch1.read();//Read the state of the microswitch 00020 Wheel.Stop();//Stop wheels 00021 rStopped = true;//Change bool state to true 00022 dist();//Check distance 00023 } 00024 } 00025 void FwdStop()//This function will stop the buggy and change the bool to true to say the buggy has been stopped from going forwards 00026 { 00027 if (mm<= 500)//Do the following if the buggy is less than 500mm to the edge of the arena 00028 { 00029 Wheel.Stop();//Stop wheels 00030 fStopped = true;//Change bool state to true 00031 dist();//Check distance 00032 } 00033 else 00034 { 00035 00036 fStopped = false; //Keep bool state false 00037 dist();//Check distance 00038 } 00039 }
Generated on Fri Aug 19 2022 10:05:00 by
1.7.2