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.
Diff: main.cpp
- Revision:
- 1:1e85a02fe11a
- Parent:
- 0:4d8b265728c9
- Child:
- 4:4b9d96e6c509
--- a/main.cpp Wed Feb 20 15:50:04 2019 +0000
+++ b/main.cpp Thu Feb 21 00:36:53 2019 +0000
@@ -1,12 +1,19 @@
#include "mbed.h"
+#include "Robot.h"
-DigitalOut myled(LED1);
+Serial pc(SERIAL_TX, SERIAL_RX);
int main() {
while(1) {
- myled = 1; // LED is ON
- wait(0.2); // 200 ms
- myled = 0; // LED is OFF
- wait(1.0); // 1 sec
+ getCountsAndReset(); // Call getCountsAndReset() to read the values of encoders
+ // and reset them. The values become available on variables
+ // "countsLeft" and "countsRight".
+
+ // setSpeeds(20, 50); // Uncomment to set a speed of 20 for the
+ // left motor and 50 for the right motor.
+
+ pc.printf("Encoders: Left=%d Right=%d\n", countsLeft, countsRight);
+
+ wait(0.5); // Delay of 0.5 seconds.
}
-}
+}
\ No newline at end of file