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: mbed PID MotorDriver Encoder
main.cpp
- Committer:
- ryosukenanoda
- Date:
- 2020-12-30
- Revision:
- 0:45bca03e9dbf
- Child:
- 1:3700098faa22
File content as of revision 0:45bca03e9dbf:
#include "mbed.h"
#include "MotorDriver.h"
#include "Encoder.h"
#include "PID.h"
Serial pc(USBTX, USBRX);
MotorDriver A(PC_9, PC_8);
Encoder E(PC_6, PC_5);
PID C(0.5, 0, 0);
int main() {
pc.printf("Hello World!");
C.set_target(4.0);
A.set_duty(50);
wait_ms(5000);
while(1) {
float raito = E.get_raito();
pc.printf("\n \r raito: %f", raito);
float input = C.get_input(raito);
pc.printf("\t input: %f", input);
if ( abs(input) > 100 ) {
continue;
}
A.set_duty(input);
wait_ms(10);
}
A.set_duty(0);
}