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
- Committer:
- CasperK
- Date:
- 2018-09-24
- Revision:
- 2:4eaaac9504fe
- Parent:
- 1:37b02778f7f3
File content as of revision 2:4eaaac9504fe:
#include "mbed.h"
#include "MODSERIAL.h"
PwmOut pwmpin(D6);
PwmOut led(D10);
AnalogIn potmeter(A5);
DigitalIn button(D2);
DigitalOut directionpin(D5);
int main()
{
pwmpin.period_us(60); //60 microsecondsPWM period, 16.7 kHz
float u = -0.3f; //determineusefulvalue, -0.3f is justanexample
directionpin= u > 0.0f; //eithertrueor false
while (true) {
pwmpin.write(potmeter); //pwm duty cycle can only be positive, floatingpoint absolute value
led.write(potmeter);
wait(0.2f);
}
}