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: Motor_Encoders mbed Motor_Driver
Diff: main.cpp
- Revision:
- 0:1fe09ed4f755
diff -r 000000000000 -r 1fe09ed4f755 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Dec 24 03:49:20 2018 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+#include "MotorDriver.h"
+#include "math.h"
+#include "Encoder.h"
+
+Serial PC(USBTX,USBRX);
+#define USBRX p14
+#define USBTX p13
+
+
+Encoder encoder(p16,p17);
+MotorDriver Motor(p21,p19,p20); // Connect to pins PWM, INA, INB
+AnalogIn senseB(p18); //Connect to pin CS
+
+int main(){
+
+ PC.baud(115200);
+ Motor.setEnabled(true);
+ encoder.setEnabled(true);
+ int i = 0;
+
+ while(1)
+ {
+ Motor.setSpeed(sin(i/180.0*3.1415));
+ PC.printf("%.3f\n\r",senseB.read());
+
+ wait(5);
+ PC.printf("%d\n\r",encoder.get_position());
+
+
+ wait(5);
+ }
+ }
\ No newline at end of file