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.
irpair.cpp
00001 #include "irpair.h" 00002 #include "mbed.h" 00003 00004 #define dark_samples 10 00005 #define busy_wait 10 00006 00007 void IRPair::calibrateSensor() { 00008 00009 ir.write( 1 ); 00010 wait_us(60); 00011 00012 for (int i = 0; i < samplesToTake; ++i) 00013 sensorAvg += recv.read(); 00014 00015 ir.write( 0 ); 00016 sensorAvg /= samplesToTake; 00017 wait_us(5); 00018 } 00019 00020 double IRPair::getSamples( int samples ) 00021 { 00022 double z = 0; 00023 00024 ir.write( 0 ); 00025 //for( int i = 0; i < dark_samples; i++ ) 00026 // z1 += recv.read(); 00027 00028 ir.write( 1 ); 00029 wait_us(60); 00030 00031 for( int i = 0; i < samples; ++i ) 00032 z += recv.read(); 00033 ir.write( 0 ); 00034 wait_us(5); 00035 return z / samples; 00036 }
Generated on Tue Jul 12 2022 17:41:24 by
1.7.2