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.
IR_Dist.cpp
00001 #include "IR_Dist.h" 00002 #include "mbed.h" 00003 /* 00004 *IR_Dist.cpp 00005 */ 00006 IR_Dist::IR_Dist(PinName a) : IRSens(a){} 00007 00008 float IR_Dist::Equation() { 00009 volts = IRSens.read_u16()* 0.02441406; // 5v / 2048 = 0.02441406 00010 00011 return 5034.2 * pow(volts,-0.959); // x = 5034.2x-0.959 00012 } 00013 00014 //return distance in cm 00015 float IR_Dist::distance(){ 00016 correction = 1; 00017 som = Equation(); 00018 distance_cm = (som - correction); 00019 00020 return distance_cm; 00021 00022 }
Generated on Fri Jul 15 2022 12:21:26 by
1.7.2