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.
Dependencies: Encoder MODSERIAL mbed
main.cpp
- Committer:
- Technical_Muffin
- Date:
- 2015-09-23
- Revision:
- 6:19b8a8d255dd
- Parent:
- 5:6fda4448a428
- Child:
- 7:2142e17a49e8
File content as of revision 6:19b8a8d255dd:
#include "mbed.h" #include "encoder.h" #include "MODSERIAL.h" DigitalOut led(LED_RED); DigitalOut direction1(D7); PwmOut speed1(D6); DigitalIn button(PTC6); Encoder motor1(D13,D12,true);// call the encoder MODSERIAL pc(USBTX,USBRX); int main() { pc.baud(115200); float maximum=1.0; direction1.write(false);//turn motor CCW or CW if set to 0 //motor CW = 0 //motor CCW = 1 while(1){//while on, turn on motor speed1.period_us(100);//Set period of PWM to 100 us. for(float cycle=0.0; cycle < maximum; cycle=cycle +0.1){ speed1.write(cycle); } } }