![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Motorprogrammaatje - the basics, enkel motor laten draaien.
Revision 0:0cb350eb704a, committed 2018-09-28
- Comitter:
- felixdransfeld
- Date:
- Fri Sep 28 09:42:48 2018 +0000
- Commit message:
- Dit is de code om de motor te laten werken - the basics
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MODSERIAL.lib Fri Sep 28 09:42:48 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Sissors/code/MODSERIAL/#a3b2bc878529
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Sep 28 09:42:48 2018 +0000 @@ -0,0 +1,33 @@ +#include "mbed.h" +#include "MODSERIAL.h" + +AnalogIn pot1(A1); +AnalogIn pot2(A2); +DigitalIn encoder(D7); +PwmOut pwmpin(D5); +DigitalOut directionpin(D4); +DigitalOut directionpin2(D6); +MODSERIAL pc(USBTX, USBRX); + +int main() +{ + pc.baud(9600); + + pwmpin.period_us(60); //60 microsecondsPWM period, 16.7 kHz + //float ain1; + //float ain2; + + while(true){ + // ain1 = pot1.read(); + // ain2 = pot2.read(); + + float u = -0.9f; //determineusefulvalue, -0.3f is justanexample + directionpin= u > 0.0f; //eithertrueor false + pwmpin= fabs(u); //pwmduty cycle canonlybepositive, floatingpoint absolute value + + wait(0.5f); + + printf("Motorsnelheid %i \n \r", encoder); + + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Sep 28 09:42:48 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187 \ No newline at end of file