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:
- roosalyn
- Date:
- 2015-09-18
- Revision:
- 1:8a78b9be5e0e
- Parent:
- 0:f5c7335c5903
File content as of revision 1:8a78b9be5e0e:
#include "mbed.h"
#include "encoder.h"
#include "MODSERIAL.h"
Encoder encoder1(D13,D12);
DigitalOut motor2direction(D4); //D4 en D5 zijn motor 2 (op het motorshield)
PwmOut motor2speed(D5);
MODSERIAL pc(USBTX,USBRX);
int round = 4200; //4200 is gelijk aan 360 graden!!!! :D
int main()
{
encoder1.setPosition(0);
pc.baud(9600);
motor2direction = 1;
motor2speed = 0.2f;
while (true) {
pc.printf("pos: %d, speed: %.20f\r\n", encoder1.getPosition(), encoder1.getSpeed());
if (encoder1.getPosition()>10*round){
motor2speed=0.0;
}
}
}