Fa2018-es200-3321-project2-goatpong
/
motors
motor code works
Revision 0:64c745fbdf05, committed 2018-10-19
- Comitter:
- m215910
- Date:
- Fri Oct 19 14:37:17 2018 +0000
- Commit message:
- motor code works
Changed in this revision
diff -r 000000000000 -r 64c745fbdf05 Motor.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Motor.lib Fri Oct 19 14:37:17 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/simon/code/Motor/#f265e441bcd9
diff -r 000000000000 -r 64c745fbdf05 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Oct 19 14:37:17 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187 \ No newline at end of file
diff -r 000000000000 -r 64c745fbdf05 motor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/motor.cpp Fri Oct 19 14:37:17 2018 +0000 @@ -0,0 +1,25 @@ +//Test Motor + +//Libraries and mechanical directives +#include "Motor.h" //must change line 31 in Motor.cpp according to Lab +#include "mbed.h" +//#include "Servo.h" //need Servo library + +Motor m(p26, p30, p29); //designates the pins used by the motor +DigitalIn sw1(p16); //switches or buttons +int sw1state, bu1state, bu2state, bu3state, bu4state, bu5state; //the state of the switch +int s=0.6; //speed of motor rotation - fairly slow so as to be exact + +int main() { + while(1) { //do we need while? + sw1state=sw1.read(); //read in switch state + + if (sw1state == 1) { //if bu4 is on rotate motor fwd + m.speed(-s); + s=1; + printf("hi");} + else { //if bu5 is on rotate motor rev + m.speed(s); + s=0;} + } + }