Pedro Cruz / Mbed 2 deprecated serialarray

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 
00004 
00005 Serial pc(USBTX, USBRX); // tx, rx
00006 
00007 int j=0;
00008 int x=0;
00009 
00010 
00011 char X_buffer []= {0,0}; //2 item array
00012 
00013 
00014 
00015 void readSerialString ()
00016 {
00017     j=0;
00018     while(j<=1) {
00019         X_buffer[j] = pc.getc();
00020         j++;
00021     }
00022 
00023 }
00024 
00025 
00026 int main()
00027 
00028 {
00029     pc.baud(115200);
00030 
00031     while(1) {
00032         readSerialString ();
00033 
00034 
00035         x=atoi(X_buffer); //convert to int
00036 
00037         pc.printf("%d\n",x);
00038 
00039     }
00040 }