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
- Committer:
- sahilmgandhi
- Date:
- 2017-05-21
- Revision:
- 28:8126a4d620e8
- Parent:
- 15:b80555a4a8b9
- Child:
- 29:ec2c5a69acd6
File content as of revision 28:8126a4d620e8:
#include "irpair.h"
#include "mbed.h"
void IRPair::calibrateSensor() {
ir.write( 1 );
for (int i = 0; i < samplesToTake; ++i)
sensorAvg += recv.read();
ir.write( 0 );
sensorAvg /= samplesToTake;
}
float IRPair::getSamples( int samples )
{
float z = 0;
ir.write( 1 );
for( int i = 0; i < samples; ++i )
z += recv.read();
ir.write( 0 );
return z / samples;
}