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
ir_sensor.cpp
00001 #include "mbed.h" 00002 #include "ir_sensor.h" 00003 00004 float IRSensor::readIR() { 00005 float value; 00006 _enable = 1; 00007 wait_us(60); 00008 value = _input.read(); 00009 _enable = 0; 00010 wait_us(60); 00011 00012 return value; 00013 00014 /* 00015 float sensor_arr [5]; 00016 //Each duration takes 100us, 5 times = 0.5ms 00017 for (int i = 0; i < 5; i++) 00018 { 00019 float value; 00020 _enable = 1; 00021 wait_us(30); 00022 sensor_arr[i] = _input.read(); 00023 _enable = 0; 00024 wait_us(30); 00025 } 00026 float sum = 0.0f; 00027 for (int i = 2; i < 5; i++) { 00028 sum += sensor_arr[i]; 00029 } 00030 00031 return sum/3;*/ 00032 } 00033 00034 //float IRSensor::cell_dist(){ 00035 // return readIR() / 18; 00036 //}
Generated on Thu Jul 14 2022 05:30:38 by
