Srinivasan Ramasamy
/
EC
Water quality
Diff: main.cpp
- Revision:
- 0:ef33eee73e62
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Dec 23 10:24:43 2014 +0000 @@ -0,0 +1,71 @@ +#include "mbed.h" +#include <stdio.h> + + +DigitalOut myled(LED1); +Serial pc(USBTX, USBRX); +Serial async_port(p9,p10); + + +int main() { + char A[100]; + char *pch; + int t=0; + + pc.printf("EC = "); + async_port.baud(38400); + //async_port.puts("27,b\r"); + + //async_port.puts("C0\r"); + + /*async_port.puts("O,S,1\r"); + wait(1); + async_port.puts("O,SG,1\r"); + wait(1); + async_port.puts("O,TDS,1\r"); + wait(1); + async_port.puts("O,EC,1\r"); + wait(1);*/ + async_port.puts("R\r"); + + //async_port.puts("L,1\r"); + + + //async_port.puts("K,1.0\r"); + //async_port.puts("Cal,dry\r"); + //async_port.puts("Cal,high,80000\r"); + //async_port.puts("Cal,low,12800\r"); + //async_port.puts("Cal,?\r"); + + wait(1); + async_port.gets(A,20); + //pc.printf(A); + pc.printf("\n\r"); + pch = strtok (A,","); + + while (pch != NULL) + { + switch(t) + { + case 0: pc.printf ("EC = %s\n",pch); break; + case 1: pc.printf ("TDS = %s\n",pch); break; + case 2: pc.printf ("SAL = %s\n",pch); break; + case 3: pc.printf ("SG = %s\n",pch); break; + + } + t++; + pch = strtok (NULL, ","); + } + /* wait(10); + pc.printf("TDS="); + async_port.puts("O,TDS,1\r"); + async_port.puts("O,EC,0\r"); + async_port.puts("R\r"); + wait(10); + async_port.gets(A,6); + pc.printf(A); + pc.printf("\n\r"); + */ + + + }