Weather data received
Dependencies: mbed
main.cpp
- Committer:
- Woffle
- Date:
- 2015-06-11
- Revision:
- 0:734fd976094f
File content as of revision 0:734fd976094f:
#include "mbed.h" Serial info(p28,p27); Serial pc(USBTX,USBRX); int main() { char message[128]; char c; int i = 0; info.baud(9600); while(1){ // pc.printf("In the while loop!"); if(info.readable()) { // pc.printf("readable!\n\r"); c = info.getc(); message[i] = c; i++; if ( c == 'l') { i = 0; } if ( c == 'L') { pc.printf("Light intensity: "); for (int j =0;j<i-1;j++) { pc.printf("%c",message[j]); } pc.printf("\n\r\n\r"); i=0; wait(1); } if ( c == 't') { i = 0; } if ( c == 'T') { pc.printf("Temperature: "); for (int j =0;j<i-1;j++) { pc.printf("%c",message[j]); } pc.printf("\n\r"); i=0; wait(1); } if ( c == 'p') { i = 0; } if ( c == 'P') { pc.printf("Pressure is: "); for (int j =0;j<i-1;j++) { pc.printf("%c",message[j]); } pc.printf("\n\r"); i=0; wait(1); } if ( c == 'h') { i = 0; } if ( c == 'H') { pc.printf("Humidity is: "); for (int j =0;j<i-1;j++) { pc.printf("%c",message[j]); } pc.printf("\n\r"); i=0; wait(1); } // pc.printf("%c",message); // pc.printf("%s",message); // pc.printf("[%s]",message); wait(0.001); // if(data == 'u') { // myled = 1; // wait(0.2); // myled = 0; // wait(0.2); // } } } }