Initial setup for different sensations on the MBED

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
mfrede
Date:
Thu Nov 05 21:38:00 2015 +0000
Commit message:
Initial code

Changed in this revision

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
diff -r 000000000000 -r f9023577fa6b main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 05 21:38:00 2015 +0000
@@ -0,0 +1,65 @@
+#include "mbed.h"
+
+Serial pc(USBTX,USBRX);
+DigitalOut port1(p21);
+DigitalOut port2(p22);
+DigitalOut port3(p20);
+DigitalOut port4(p19);
+DigitalOut port5(p25);
+DigitalOut port6(p26);
+
+int main() {
+    char buffer;
+    while(1) {
+        pc.printf("Press any key to generate a sensation\r\n");
+        buffer = pc.getc();
+        if (buffer == 'c') {
+            port1 = 1;
+            wait_ms(200);
+            port2 = 1;
+            port1 = 0;
+            wait_ms(200);
+            port3 = 1;
+            port2 = 0;
+            wait_ms(200);
+            port4 = 1;
+            port3 = 0;
+            wait_ms(200);
+            port5 = 1;
+            port4 = 0;
+            wait_ms(200);
+            port6 = 1;
+            port5 = 0;
+            wait_ms(200);
+            port6 = 0;
+        } else {
+            port1 = 1;
+            port2 = 1;
+            port3 = 1;
+            port4 = 1;
+            port5 = 1;
+            port6 = 1;
+            wait_ms(1000);
+            port1 = 0;
+            port2 = 0;
+            port3 = 0;
+            port4 = 0;
+            port5 = 0;
+            port6 = 0;
+            wait_ms(100);
+            port1 = 1;
+            port2 = 1;
+            port3 = 1;
+            port4 = 1;
+            port5 = 1;
+            port6 = 1;
+            wait_ms(1000);
+            port1 = 0;
+            port2 = 0;
+            port3 = 0;
+            port4 = 0;
+            port5 = 0;
+            port6 = 0;
+        }
+    }
+}
diff -r 000000000000 -r f9023577fa6b mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 05 21:38:00 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68
\ No newline at end of file