![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
This is a test program for the eee@ncl project
Dependencies: mbed SHT21_ncleee
Diff: main.cpp
- Revision:
- 2:b7ce3ec3d45d
- Parent:
- 1:9d26ddb57191
diff -r 9d26ddb57191 -r b7ce3ec3d45d main.cpp --- a/main.cpp Thu Nov 29 15:54:53 2012 +0000 +++ b/main.cpp Thu Dec 06 10:38:37 2012 +0000 @@ -1,17 +1,31 @@ -#include "mbed.h" - -DigitalOut myled(LED1); -Serial pc(USBTX, USBRX); - -int main() { - - while(1) //loop forever - { - for(int i=0; i<10; i++) //count from 0 to 9 - { - myled = !myled; //toggle LED - pc.printf("%d\n",i); //send a character to the PC, PC will see '0' in Ascii which is equal to 48 in dec, 30 in hex - wait(1.0); - } - } -} +#include "mbed.h" +#include "SHT21_ncleee.h" + + +DigitalOut myled(LED1); +Serial pc(USBTX, USBRX); +I2C i2c(p28,p27); +SHT21 sht(&i2c); + + +int main() { + + pc.printf("Hello World...\n Testing temperature and humidity sensor\n"); + + float temperature; + float humidity; + + + while(1) { + temperature = sht.readTemp(); + humidity = sht.readHumidity(); + + + pc.printf("Temperature=%.1f%cC Humidity=%.1f%%\n",temperature,248,humidity); + + myled = 1; + wait(2.5); + myled = 0; + wait(2.5); + } +}