Programma om motor 1 aan te sturen
Dependencies: Encoder MODSERIAL mbed-dsp mbed
Fork of motor1aansturing by
Revision 28:fa85793c50bb, committed 2014-10-20
- Comitter:
- MarijkeAbma
- Date:
- Mon Oct 20 12:13:50 2014 +0000
- Parent:
- 27:fb73c8b5321a
- Commit message:
- Ready for publishing
Changed in this revision
HIDScope.lib | Show diff for this revision Revisions of this file |
motor2.cpp | Show diff for this revision Revisions of this file |
diff -r fb73c8b5321a -r fa85793c50bb HIDScope.lib --- a/HIDScope.lib Mon Oct 20 07:37:46 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://developer.mbed.org/teams/BMT-M9-Groep01/code/HIDScope/#9f55d4fb48ea
diff -r fb73c8b5321a -r fa85793c50bb motor2.cpp --- a/motor2.cpp Mon Oct 20 07:37:46 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -#include "mbed.h" -#include "encoder.h" - -int main() -{ - Encoder motor1(PTD0,PTC9); - PwmOut pwm_motor(PTA5); - pwm_motor.period_us(100); - DigitalOut motordir(PTD1); - int pos = 0; // variable to store the servo position -} - -void loop() -{ -for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees, limit to other degree? -{ // in steps of 1 degree -pwm_motor.write(pos); // tell motor to go to position in variable 'pos' -delay(15); // waits 15ms for the motor to reach the position -} - -//back to starting position: -for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees -{ -pwm_motor.write(pos); // tell servo to go to position in variable 'pos' -delay(15); // waits 15ms for the servo to reach the position \ No newline at end of file