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: MODSERIAL QEI mbed-dsp mbed
Fork of Motorcode by
Revision 8:9b517db94f49, committed 2018-10-01
- Comitter:
- rachieldb
- Date:
- Mon Oct 01 12:47:32 2018 +0000
- Parent:
- 7:e21056555296
- Child:
- 9:466dff9ae128
- Commit message:
- draaien van beide richtingen toegevoegd;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Sep 25 11:55:40 2018 +0000
+++ b/main.cpp Mon Oct 01 12:47:32 2018 +0000
@@ -32,9 +32,12 @@
while (true)
{
- pwmpin.write(pot1.read());
- direct = 1;
- pc.printf("potmeter: %f, encoder: %i \r\n", pot1.read(), encoder.getPulses());
+ float pot1_float = pot1.read();
+ float pot1_motor = (pot1_float * 2.0f) - 1.0f;
+ int mot1_direction = pot1_motor >= 0;
+ pwmpin.write(fabs(pot1_motor));
+ direct = mot1_direction;
+ pc.printf("potmeter: %f, encoder: %i \r\n", pot1_motor, encoder.getPulses());
wait(0.2f);
}
}
