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
00001 #include "mbed.h" 00002 #include "MODSERIAL.h" 00003 00004 AnalogIn pot1(A1); 00005 AnalogIn pot2(A2); 00006 DigitalIn encoder(D7); 00007 PwmOut pwmpin(D5); 00008 DigitalOut directionpin(D4); 00009 DigitalOut directionpin2(D6); 00010 MODSERIAL pc(USBTX, USBRX); 00011 00012 int main() 00013 { 00014 pc.baud(9600); 00015 00016 pwmpin.period_us(60); //60 microsecondsPWM period, 16.7 kHz 00017 //float ain1; 00018 //float ain2; 00019 00020 while(true){ 00021 // ain1 = pot1.read(); 00022 // ain2 = pot2.read(); 00023 00024 float u = -0.9f; //determineusefulvalue, -0.3f is justanexample 00025 directionpin= u > 0.0f; //eithertrueor false 00026 pwmpin= fabs(u); //pwmduty cycle canonlybepositive, floatingpoint absolute value 00027 00028 wait(0.5f); 00029 00030 printf("Motorsnelheid %i \n \r", encoder); 00031 00032 } 00033 }
Generated on Thu Jul 14 2022 09:42:05 by
1.7.2