GROVE -温度センサ サンプルプログラム

Dependencies:   mbed

Committer:
jksoft
Date:
Fri Nov 29 07:49:32 2013 +0000
Revision:
0:fe99878e5849
Rev1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:fe99878e5849 1 #include "mbed.h"
jksoft 0:fe99878e5849 2
jksoft 0:fe99878e5849 3 BusOut myleds(LED1, LED2, LED3, LED4);
jksoft 0:fe99878e5849 4 AnalogIn SoundSensor(p15);
jksoft 0:fe99878e5849 5
jksoft 0:fe99878e5849 6 int main() {
jksoft 0:fe99878e5849 7 while(1) {
jksoft 0:fe99878e5849 8 float value = TemperatureSensor;
jksoft 0:fe99878e5849 9 int ledbit = 0x00;
jksoft 0:fe99878e5849 10
jksoft 0:fe99878e5849 11 if( value > 0.8 ) {
jksoft 0:fe99878e5849 12 ledbit = 0x0F;
jksoft 0:fe99878e5849 13 }
jksoft 0:fe99878e5849 14 else if( value > 0.6 ) {
jksoft 0:fe99878e5849 15 ledbit = 0x07;
jksoft 0:fe99878e5849 16 }
jksoft 0:fe99878e5849 17 else if( value > 0.4 ) {
jksoft 0:fe99878e5849 18 ledbit = 0x03;
jksoft 0:fe99878e5849 19 }
jksoft 0:fe99878e5849 20 else if( value > 0.2 ) {
jksoft 0:fe99878e5849 21 ledbit = 0x01;
jksoft 0:fe99878e5849 22 }
jksoft 0:fe99878e5849 23 else {
jksoft 0:fe99878e5849 24 ledbit = 0x00;
jksoft 0:fe99878e5849 25 }
jksoft 0:fe99878e5849 26 printf("Value = %f\r\n",value);
jksoft 0:fe99878e5849 27 wait(0.2);
jksoft 0:fe99878e5849 28 }
jksoft 0:fe99878e5849 29 }