Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- wesqeek
- Date:
- 2016-11-25
- Revision:
- 0:ab9d6f1ea254
File content as of revision 0:ab9d6f1ea254:
#include "mbed.h"
DigitalIn switch1(p17); //Switch in original position
DigitalIn switch2(p18); //Switch turned to the right position
DigitalIn killswitch(p23);
DigitalOut transistor1(p21);
DigitalOut transistor2(p22);
int main() {
while(1) {
if (switch1==0&& switch2==1&& killswitch==0){ //If the switch is in the orignial position the kill switch is closed
transistor1=0; //transistor 1 is off
transistor2=0; //trnsistor 2 is off
}
else if (switch1==1&& switch2==0){ //If the switch is in the right position
transistor1=1; //Transistor 1 is off
transistor2=0; //Transistor 2 is on so the motor is working clockwise
}
else if (switch1==0&& switch2==1&& killswitch==1){ //If the switch is back in the original position and the kill switch is open
transistor1=0; //Transistor 1 is on
transistor2=1; //Transisotr 2 is off and since transistor 1 is on the motor will work anticlockwise
}
}
}