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.
Fork of PWM_motor by
Revision 2:c63f3fab88d9, committed 2018-10-01
- Comitter:
- felixdransfeld
- Date:
- Mon Oct 01 13:28:02 2018 +0000
- Parent:
- 1:2ec710725db2
- Commit message:
- //Nieuwe versie van 01/10/2018
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Sep 28 09:58:57 2018 +0000
+++ b/main.cpp Mon Oct 01 13:28:02 2018 +0000
@@ -1,7 +1,7 @@
#include "mbed.h"
#include "MODSERIAL.h"
-//AnalogIn pot1(A1);
+AnalogIn pot1(A1);
//AnalogIn pot2(A2);
DigitalIn encoder(D8);
PwmOut pwmpin1(D5);
@@ -16,14 +16,16 @@
pwmpin1.period_us(60); //60 microsecondsPWM period, 16.7 kHz
pwmpin2.period_us(60);
- //float ain1;
+ float ain1;
//float ain2;
while(true){
- // ain1 = pot1.read();
+ ain1 = pot1.read();
// ain2 = pot2.read();
- float u = -0.9f; //determineusefulvalue, -0.3f is justanexample
+
+
+ float u = ain1; //determineusefulvalue, -0.3f is justanexample
directionpin= u > 0.0f; //eithertrueor false
pwmpin1= fabs(u); //pwmduty cycle canonlybepositive, floatingpoint absolute value
pwmpin2= fabs(u);
