Fa2018-es200-3321-project2-goatpong
/
motors
motor code works
motor.cpp
- Committer:
- m215910
- Date:
- 2018-10-19
- Revision:
- 0:64c745fbdf05
File content as of revision 0:64c745fbdf05:
//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;} } }