---

Dependencies:   mbed

Fork of MicroMouse_MASTER_FIVE by PES2_R2D2.0

CheckWalls.cpp

Committer:
TheDarkDurzo
Date:
2018-05-23
Revision:
11:8c8dba56bfda
Parent:
9:ab19796bf14a

File content as of revision 11:8c8dba56bfda:

#include <cmath>
#include "CheckWalls.h"

using namespace std;

const float CheckWalls::WALL_DISTANCE = 100.0f;

CheckWalls::CheckWalls(IRSensor& irSensor0, IRSensor& irSensor1, IRSensor& irSensor2, int& wallRight, int& wallFront, int& wallLeft):
    irSensor0(irSensor0),
    irSensor1(irSensor1),
    irSensor2(irSensor2),
    wallRight(wallRight),
    wallFront(wallFront),
    wallLeft(wallLeft)
 
{

}

CheckWalls::~CheckWalls() {}

void CheckWalls::check(){
        
        if (irSensor0.read() < WALL_DISTANCE){ //Abstand zur RECHTEN WAND                        
            wallRight = 1; //Wand
        }else{                   
            wallRight = 0; //keine Wand 
        }     
                
        if (irSensor1.read() < WALL_DISTANCE){ //Abstand zur WAND VORNE
            wallFront = 1;  //Wand
        }else{
            wallFront = 0;  //Keine Wand
        }
                
        if (irSensor2.read() < WALL_DISTANCE){ //Anbstand zur LINKEN WAND                        
            wallLeft = 1;   //Wand
        }else{               
            wallLeft = 0;   //keine Wand 
        }                    
}