Programming Milestone Group 7 BMT M9

Dependencies:   FastPWM MODSERIAL mbed

main.cpp

Committer:
MAHCSnijders
Date:
2018-09-25
Revision:
0:1e216b50d323
Child:
1:67b19c59b8c9

File content as of revision 0:1e216b50d323:

#include "mbed.h"

PwmOut pwmpin();
DigitalOut directionpin();
pwmpin.period_us(60); //60 microseconds PWM period, 16.7 kHz
AnalogIn potmeter();  // Analoge input van potmeter

int main()
{
    while (true) {
        float u = -0.3f; //determine useful value, -0.3f is just an example
        directionpin = u > 0.0f; //either true or false
        pwmpin = fabs(u); //pwm duty cycle can only be positive, floating point absolute value
        float pot = potmeter.read();
    }
}