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
Diff: main.cpp
- Revision:
- 0:c65497674c14
diff -r 000000000000 -r c65497674c14 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Dec 11 16:49:21 2017 +0000
@@ -0,0 +1,56 @@
+#include "mbed.h"
+
+AnalogIn a1(A0);
+BusOut M1(D2,D3,D4,D5);
+Serial pc(USBTX,USBRX); //para leer serial y mandarlo a la PC
+
+char pos[4]={0x0A,0x09,0x05,0x06};
+char pos2[4]={0x05,0x09,0x0A,0x06};
+int i;
+int j;
+int k;
+char l;
+
+int main()
+{
+ i=0;
+ j=0;
+ k=0;
+
+
+ while (1)
+ {
+
+ j=248*a1.read();
+ wait(0.01);
+ /* l=l+j;
+ j=0;
+ j=248*a1.read();
+ wait(0.005);
+ l=l+j;
+ j=0;
+ l=l/2;
+ j=l;
+ */
+
+ printf(" = %d\n",j);
+
+ // pc.getc();
+ if(k<j)
+ {
+ M1=pos[i];
+ wait(0.003);
+ i++;
+ k++;
+ if(i==4) {i=0;}
+ }
+ if(k>j)
+ {
+ M1=pos2[i];
+ wait(0.003);
+ i++;
+ k--;
+ if(i==4) {i=0;}
+ }
+ }
+}
\ No newline at end of file