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 Servo ServoArm
Fork of PES_Yanick by
Sources/Farbsensor.cpp
- Committer:
- beacon
- Date:
- 2017-04-26
- Revision:
- 6:ba26dd3251b3
- Parent:
- 4:67d7177c213f
- Child:
- 10:f76476943a6c
File content as of revision 6:ba26dd3251b3:
#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();
}
