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:
- 4:646f8d3f0643
- Parent:
- 3:8583035f898b
- Child:
- 5:6fda4448a428
File content as of revision 4:646f8d3f0643:
#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); //motor CW = 0 //motor CCW = 1 while(1){//as long as button is pressed turn on motor direction1.write(1);//turn motor CCW speed1.write(1.0);//Set speed of motor to full. wait(0.2); pc.printf("pos: %d, speed %f \r\n",motor1.getPosition(), motor1.getSpeed()); // X unit counts equals one magnet shaft rotation, with X being 64 } }