アナログ入力_振動センサ

Dependencies:   TextLCD mbed

振動センサに入力があるとLEDを点灯

参考 https://mbed.org/users/okini3939/notebook/AnalogIn_jp/

main.cpp

Committer:
hasimo
Date:
2014-07-23
Revision:
0:18ca468a910f

File content as of revision 0:18ca468a910f:

#include "mbed.h"

AnalogIn ain(p15);
DigitalOut myled(p5);

int main() {
    float adc, volts;
    
    myled = 0;
    
    while (1){
        adc = ain.read();           // read analog as a float
        volts = adc * 3.3;          // convert to volts
        if(volts > 1.0){
            myled = 1;
        }else{
            myled = 0;
        }
        //wait(0.5);                 //
    }
}