Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 3:0ef302d879b4, committed 2017-12-05
- 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