Felix Dransfeld / Mbed 2 deprecated PWM_motor_maas

Dependencies:   MODSERIAL mbed

Fork of PWM_motor by Casper Maas

Files at this revision

API Documentation at this revision

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);