Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Versuch20 by
IRSensorGF.cpp
00001 #include <cmath> 00002 #include "IRSensorGF.h" 00003 00004 //------------------------------------------------------------------------------ 00005 00006 using namespace std; 00007 00008 IRSensorGF::IRSensorGF(AnalogIn& distance): 00009 00010 distance(distance) 00011 { 00012 00013 00014 } 00015 00016 IRSensorGF::~IRSensorGF() {} 00017 00018 //------------------------------------------------------------------------------ 00019 00020 int IRSensorGF::read() 00021 { 00022 int d; 00023 00024 /*if (3300*(distance)>2900){ //5-6cm 00025 d=1; 00026 } 00027 else{ 00028 d=0; 00029 }*/ 00030 00031 int w = 10/(distance)*exp(1.4481); 00032 00033 if (w < 150) { 00034 d=1; 00035 } else { 00036 d=0; 00037 } 00038 00039 return w; 00040 00041 }
Generated on Sun Jul 17 2022 11:46:13 by
