Lab05 pseudocode

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
m215130
Date:
Thu Feb 21 12:43:09 2019 +0000
Commit message:
Pseudocode lab05, 1st draft

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Feb 21 12:43:09 2019 +0000
@@ -0,0 +1,63 @@
+#include "mbed.h"
+#include <ctype.h>
+Serial pc(USBTX, USBRX); // tx, rx
+DigitalOut led(LED1); //options for serial and light
+DigitalOut led2(LED4);//second led
+
+
+int main(){
+     while(1){
+        //write options for user to select from
+        pc.printf("\nA: USNA \n B: 2021 \n C: CyberOps \n");
+        char in = pc.getc();  // this function will get the user choice
+        switch(in){  // these are the options for "in" response
+            case 'A':
+                morse("USNA", outstring);
+                break;
+            case 'B': 
+                morse("2021", outstring);
+                break;
+            case 'C':
+                morse("CyberOps", outstring);
+                break;
+            case 'q': case 'Q':
+                exit(0);
+            default:
+                pc.printf("\n ERROR INVALID OPTION");   
+        }
+//"40 letters per minute is used for flashing light transmission of Morse code (approximately 200 milliseconds per “dot” or
+//“unit”). Additionally, the space between any two elements of a symbol, between letters, and between words
+//should follow the requirements of these sections."
+    
+// FOR EXTRA CREDIT:
+    
+    //Prompt user for input, and store as a string 
+        //end signal by pressing enter key*
+    
+        //Be sure user inputs meet specified requirements, string <= 50 chars, only containing letters, numbers, and spaces
+            //check for valid input
+                // if invalid input, request another message (while loop)
+        morse(instring,outstring,led); //call morse to translate for LED1
+            
+    //***Repeat above process for LED2.
+        morse(instring2, outstring2,led2);
+        //call morse to translate for LED4
+}
+
+    
+//define function to handle input and translate to morse code.
+void morse(char* x, char* y, DigitalOut lednum){//x is the instring, y is the out, passed by ref
+                           //so we can use same char * whole program
+                //can use-->   https://os.mbed.com/users/jkhan/notebook/morse-code/
+                    // 0 is off, 1 is dot, 3 is slash
+                    
+                //test each individual letter (to be translated) for equality in cases
+                    //apply match to a variable to be called in for transmit function
+}
+
+//define function to transmit morse data to LEDs    
+void transmit(char* x, DigitalOut lednum){
+    //create time variable for proper output
+    //Run through cases to see where 0, 1, and 3 apply
+        // run through each LED individually
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Feb 21 12:43:09 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file