Junichi Katsu
/
Grove_MoistureSensor
GROVE - 水分センサ サンプルプログラム
Diff: main.cpp
- Revision:
- 1:19779dd61a09
- Parent:
- 0:94d8bb4e5fc1
diff -r 94d8bb4e5fc1 -r 19779dd61a09 main.cpp --- a/main.cpp Fri Nov 29 07:44:28 2013 +0000 +++ b/main.cpp Sat Nov 30 01:55:48 2013 +0000 @@ -1,5 +1,7 @@ #include "mbed.h" +#define GAIN 10.0 + BusOut myleds(LED1, LED2, LED3, LED4); AnalogIn MoistureSensor(p15); @@ -8,6 +10,8 @@ float value = MoistureSensor; int ledbit = 0x00; + value *= GAIN; + if( value > 0.8 ) { ledbit = 0x0F; } @@ -23,6 +27,8 @@ else { ledbit = 0x00; } + + myleds = ledbit; printf("Value = %f\r\n",value); wait(0.2); }