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: BufferedSerial DRV8833 mbed
Fork of HelloWorld by
Revision 2:375e29585498, committed 2015-10-20
- Comitter:
- mrayy
- Date:
- Tue Oct 20 08:35:55 2015 +0000
- Parent:
- 1:03c191369089
- Commit message:
- First Commit;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BufferedSerial.lib Tue Oct 20 08:35:55 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/sam_grove/code/BufferedSerial/#8287e83943f0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DRV8833.lib Tue Oct 20 08:35:55 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/xeta05/code/DRV8833/#0aa2cdeb2e2b
--- a/main.cpp Sun Jan 01 20:57:57 2012 +0000
+++ b/main.cpp Tue Oct 20 08:35:55 2015 +0000
@@ -1,12 +1,53 @@
#include "mbed.h"
+#include "DRV8833.h"
+#include "BufferedSerial.h"
+
-DigitalOut myled(LED1);
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
+
+Serial pc(USBTX, USBRX);
+ int err;
+DRV8833 motor1(p21,p22);
+DRV8833 motor2(p23,p24);
+DRV8833 motor3(p25,p26);
+
int main() {
- while(1) {
- myled = 1;
- wait(0.2);
- myled = 0;
- wait(0.2);
+ pc.baud(115200);
+ motor1.period(0.0000035f);
+ motor2.period(0.0000035f);
+ motor3.period(0.0000035f);
+ float s1,s2,s3;
+ while (1) {
+ if(pc.readable())
+ {
+ char c;
+ err=pc.scanf("%c",&c);
+ if(c=='t')
+ {
+ pc.printf("r\n");
+ led2 = 1;
+ wait(0.1);
+ led2=0;
+ }else if(c=='d')
+ {
+ // printf("reading bytes\n");
+ int m1,m2,m3;
+ err=pc.scanf("%d %d %d",&m1,&m2,&m3);
+ s1=(float)(m1)/(float)1000.0f;
+ s2=(float)(m2)/(float)1000.0f;
+ s3=(float)(m3)/(float)1000.0f;
+
+ motor1.speed(s1);
+ motor2.speed(s2);
+ motor3.speed(s3);
+
+ // printf("%f,%f,%f\n",s1,s2,s3);
+ }
+ // led1 = !led1;
+ }
}
-}
+}
\ No newline at end of file
--- a/mbed.bld Sun Jan 01 20:57:57 2012 +0000 +++ b/mbed.bld Tue Oct 20 08:35:55 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/078e4b97a13e +http://mbed.org/users/mbed_official/code/mbed/builds/031413cf7a89 \ No newline at end of file
