TAKT 平林 / AnalogInBaseClass
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers AnalogInBaseClass.cpp Source File

AnalogInBaseClass.cpp

00001 #include "AnalogInBaseClass.h"
00002 #include "mbed.h"
00003  
00004 AnalogInBaseClass::AnalogInBaseClass(PinName pin) : _pin(pin) {
00005 }
00006 float AnalogInBaseClass::read(void){
00007     
00008     int count = 20;
00009 
00010     float meas = 0;
00011     float measAll = 0;
00012     for(int i = 0; i < count; i++){
00013         meas = _pin.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
00014         meas = meas * 3300; // Change the value to be in the 0 to 3300 range
00015         measAll+= meas;
00016     }
00017     return measAll/count;
00018 }