El de mi banda transportadora + FPGA

Files at this revision

API Documentation at this revision

Comitter:
adrianmb
Date:
Tue Dec 13 02:36:59 2011 +0000
Commit message:
El de mi banda transportadora + FPGA

Changed in this revision

Servo.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Tue Dec 13 02:36:59 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Servo/#36b69a7ced07
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Dec 13 02:36:59 2011 +0000
@@ -0,0 +1,65 @@
+#include "mbed.h"
+#include "Servo.h"
+
+Servo servo(p21);
+
+DigitalOut l1(LED1);
+DigitalOut l2(LED2);
+DigitalOut l3(LED3);
+
+DigitalIn posServo(p26);
+DigitalOut ready(p27);
+DigitalOut figura(p28);
+InterruptIn inicio(p29);
+InterruptIn foto(p30);
+
+Serial pc(USBTX,USBRX);
+char in;
+
+void tomarFoto() {
+    pc.putc('f');
+    l3=1;
+    ready=0;
+}
+
+void reset() {
+    ready=0;
+    figura=0;
+    l3=0;
+}
+
+void dataIn() {
+    if (pc.readable()) {
+        in=pc.getc();
+        switch (in) {
+            case '0':
+                figura=0;
+                ready=1;
+                break;
+            case '1':
+                figura=1;
+                ready=1;
+                break;
+        }
+    }
+}
+
+int main() {
+    pc.baud(9600);
+    pc.attach(&dataIn);
+    foto.rise(&tomarFoto);
+    inicio.rise(&reset);
+    foto.mode(PullDown);
+    inicio.mode(PullDown);
+    posServo.mode(PullDown);
+
+    while (1) {
+        l1=ready;
+        l2=figura;
+        if (posServo==1) {
+            servo=1;
+        } else {
+            servo=0;
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Dec 13 02:36:59 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912