
GROVE - 光センサ サンプルプログラム
main.cpp
- Committer:
- jksoft
- Date:
- 2013-11-29
- Revision:
- 0:9a4f94089a39
- Child:
- 1:1b7b641caea5
File content as of revision 0:9a4f94089a39:
#include "mbed.h" BusOut myleds(LED1, LED2, LED3, LED4); AnalogIn LightSensor(p15); int main() { while(1) { float value = LightSensor; int ledbit = 0x00; 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; } printf("Value = %f\r\n",value); wait(0.2); } }