Do NOT modify!

Dependencies:   mbed Servo ServoArm

Fork of PES_Yanick by zhaw_st16b_pes2_10

Sources/Farbsensor.cpp

Committer:
beacon
Date:
2017-05-02
Revision:
9:ac362674c480

File content as of revision 9:ac362674c480:

#include "Robot.h"
#include "Declarations.h"


Farbsensor::Farbsensor()
{   
}

Farbsensor::Farbsensor(AnalogIn* FarbVoltage)
{
    init(FarbVoltage);  
}

void Farbsensor::init(AnalogIn* FarbVoltage)
{
    this->FarbVoltage= FarbVoltage;
}

int Farbsensor::read()
{
    int farbe;  
    float Ufarbsensor=FarbVoltage->read();
    Ufarbsensor=Ufarbsensor*3300; //Set the Voltage between 0mV und 3300mV

    if ((Ufarbsensor > GREEN_DOWNLIMIT) && (Ufarbsensor < GREEN_UPLIMIT))
        {
         farbe=1;
        }
    else if(Ufarbsensor < RED_UPLIMIT)
        {
         farbe=-1;
        }
    else 
        {
         farbe=0;
        }
    return farbe;
}

Farbsensor::operator int()
{
    return read();
}