Mauricio Mutai / Mbed 2 deprecated wired_uart_tx_test

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
mmutai
Date:
Tue Dec 05 02:38:25 2017 +0000
Parent:
2:130a5e5afb89
Commit message:
Add Dev's code for reading temp sensor

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Nov 17 18:45:32 2017 +0000
+++ b/main.cpp	Tue Dec 05 02:38:25 2017 +0000
@@ -1,15 +1,51 @@
+/*  
+ *  UART TX TEST CODE
+ *
+ *
+ */
+ 
 #include "mbed.h"
-
-#define END_BYTE   0xFF
-#define START_BYTE 0x80
-
+#include <string>
+ 
+/*
 DigitalOut myled(LED1);
-
-Serial uart(p9, p10, 115200); // tx, rx, baud
-
+ 
+char *msg = "test message \r\n";
+char *msg_begin = &msg[0];
+ 
+Serial uart(p9, p10, 9600); // tx, rx, baud
+ 
 int main() {
     while(1) {
-        uart.putc('a');
-        wait_ms(1);
+        uart.putc(*(msg++));
+        wait_ms(10);
+        if (!*msg){
+            msg = msg_begin;    
+        }
     }
 }
+*/
+ 
+ 
+AnalogIn ain(p15);
+Serial pc(USBTX, USBRX); // tx, rx
+Serial uart(p9, p10, 9600);
+ 
+float temp;
+char temp_str[20];
+ 
+int main() {
+    while(1) {
+        temp = 100*3.3*ain.read();
+        
+        sprintf(temp_str, "%2.2f deg. F\r\n", temp);
+        
+        for (int i = 0; i < 20; i++) {
+            uart.putc(temp_str[i]);
+            //wait_ms(1);
+        }
+        
+        //pc.printf("temp = %2.2f deg. F\r\n", temp);
+    }
+}               
+         
\ No newline at end of file