Junichi Katsu
/
Grove_MoistureSensor
GROVE - 水分センサ サンプルプログラム
main.cpp
- Committer:
- jksoft
- Date:
- 2013-11-30
- Revision:
- 1:19779dd61a09
- Parent:
- 0:94d8bb4e5fc1
File content as of revision 1:19779dd61a09:
#include "mbed.h" #define GAIN 10.0 BusOut myleds(LED1, LED2, LED3, LED4); AnalogIn MoistureSensor(p15); int main() { while(1) { float value = MoistureSensor; int ledbit = 0x00; value *= GAIN; if( value > 0.8 ) { ledbit = 0x0F; } else if( value > 0.6 ) { ledbit = 0x07; } else if( value > 0.4 ) { ledbit = 0x03; } else if( value > 0.2 ) { ledbit = 0x01; } else { ledbit = 0x00; } myleds = ledbit; printf("Value = %f\r\n",value); wait(0.2); } }