asdf

Dependencies:   L3GD20 LSM303DLHC mbed

Headers/Sensors.h

Committer:
goy5022
Date:
2014-04-03
Revision:
5:9e504a5a1f48
Parent:
4:ecfe2115e9a4
Child:
6:6e96e93689df

File content as of revision 5:9e504a5a1f48:

#ifndef SENSORS_H
#define SENSORS_H

//#include "Core.h"

#include "ExponentialAverage.h"
#include "L3GD20.h"
#include "LSM303DLHC.h"


float ax, ay, az;
float mx, my, mz;
float gx, gy, gz;

L3GD20 gyro(p9, p10);
LSM303DLHC compass(p9, p10);
PwmOut ledF(p23);
PwmOut ledR(p21);
PwmOut ledL(p22);
AnalogIn SenseR(p15);
AnalogIn SenseL(p16);
AnalogIn SenseF(p17);
bool wallfront = false;
bool wallright = false;
bool wallleft = false;
float cal_R =0, cal_L =0, cal_F =0;

float linearize(float sensor)
{
 return abs(log(1-sensor));  
}    


bool wallFront()
{
    return frontExpAvg.average() > .90;
}
bool wallLeft()
{
    return linearize(SenseL.read()) < 5.2;
}
bool wallRight()
{
    return linearize(SenseR.read()) < 5.2;
}
void check_walls()
{
  wallLeft();
  wallRight();
  wallFront();  
    
}
#endif