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.
Dependencies: mbed TrapezoidControl QEI Pulse LM61CIZ
USS.cpp
00001 #include "USS.h" 00002 #include "mbed.h" 00003 00004 USS::USS(PinName echoPin, PinName trigPin, PinName tempPin) 00005 :echo_(echoPin), trig_(trigPin), temp_(tempPin) 00006 { 00007 distance_ = 0; 00008 00009 } 00010 00011 double USS::ReadDis(void) { 00012 int temp = temp_.getTemperature(); 00013 double duration = echo_.read_high_us(5000); 00014 trig_.write_us(1,10); 00015 if(duration > 0){ 00016 duration /= 2; 00017 double sspead = 331.5+0.6*temp; 00018 distance_ = duration*sspead*100/1000000; 00019 } else distance_ = 0; 00020 return distance_; 00021 } 00022 00023 double USS::GetDis(void) { 00024 return distance_; 00025 }
Generated on Tue Jul 12 2022 15:21:28 by
