Yinglei Zhang / Mbed 2 deprecated HighSpeedMiPi

Dependencies:   mbed

Fork of HelloWorld by Simon Ford

Files at this revision

API Documentation at this revision

Comitter:
Yinglei
Date:
Thu Mar 03 14:18:44 2016 +0000
Parent:
1:03c191369089
Commit message:
Set up connection between the dev board and putty on PC. ; Control Break or pull down nR is equivalent to reset button, which will run the bin file in the MCU.; Figure out how to communicate between Putty and dev board and how to control all the leds;

Changed in this revision

flashLED.cpp Show annotated file Show diff for this revision Revisions of this file
flashLED.h 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flashLED.cpp	Thu Mar 03 14:18:44 2016 +0000
@@ -0,0 +1,58 @@
+#include "mbed.h"
+
+DigitalOut myled1(LED1);
+DigitalOut myled2(LED2);
+DigitalOut myled3(LED3);
+DigitalOut myled4(LED4);
+
+void FlashAll(){
+    int count=0;
+    while(count<3){
+        myled1 = 1;
+        myled2 = 1;
+        myled3 = 1;
+        myled4 = 1;
+        wait(0.1);
+        myled1 = 0;
+        myled2 = 0;
+        myled3 = 0;
+        myled4 = 0;
+        wait(0.1);
+        count++;
+    }    
+}
+
+void ResetLED(){
+    myled1 = 0;
+    myled2 = 0;
+    myled3 = 0;
+    myled4 = 0;
+}
+
+void FlashInSequence(){
+    int count = 0;
+    while(count<5) {
+        myled1 = 1;
+        myled2 = 0;
+        myled3 = 0;
+        myled4 = 0;
+        wait(0.2);
+        myled1 = 0;
+        myled2 = 1;
+        myled3 = 0;
+        myled4 = 0;
+        wait(0.2);
+        myled1 = 0;
+        myled2 = 0;
+        myled3 = 1;
+        myled4 = 0;
+        wait(0.2);
+        myled1 = 0;
+        myled2 = 0;
+        myled3 = 0;
+        myled4 = 1;
+        wait(0.2);
+        count++;
+    }
+    ResetLED();
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flashLED.h	Thu Mar 03 14:18:44 2016 +0000
@@ -0,0 +1,6 @@
+
+
+/****   flashLED.cpp    *****/
+void FlashAll();
+void FlashInSequence();
+void ResetLED();
\ No newline at end of file
--- a/main.cpp	Sun Jan 01 20:57:57 2012 +0000
+++ b/main.cpp	Thu Mar 03 14:18:44 2016 +0000
@@ -1,12 +1,26 @@
 #include "mbed.h"
+#include "flashLED.h"
 
-DigitalOut myled(LED1);
+Serial pc(USBTX, USBRX); // tx, rx
+
+LocalFileSystem local("local");
 
 int main() {
-    while(1) {
-        myled = 1;
-        wait(0.2);
-        myled = 0;
-        wait(0.2);
+    char buffer[128];
+    FILE *fp = fopen("/local/sample.txt", "r");
+    if(fp==NULL){
+        pc.printf("Error opening file.\n");
     }
+    
+    while(fgets(buffer,sizeof(buffer), fp)!=NULL){
+        FlashAll();
+        for(int i=0;i<7;i++){
+            pc.printf("%c", buffer[i]);
+        } 
+    }
+    
+    pc.printf("\n");
+    pc.printf("All commands sent.\n");
+    pc.printf("\n");
+    fclose(fp);
 }