![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
a
Dependencies: Servo ServoArm mbed
Fork of PES_Official-TestF by
Sources/Farbsensor.cpp
- Committer:
- EpicG10
- Date:
- 2017-05-10
- Revision:
- 13:6c1f8e35b242
- Parent:
- 12:c0bcb95885dd
File content as of revision 13:6c1f8e35b242:
#include "Robot.h" #include "Declarations.h" Serial pc1(USBTX, USBRX); Farbsensor::Farbsensor() { } Farbsensor::Farbsensor(AnalogIn* FarbVoltage) { init(FarbVoltage); } void Farbsensor::init(AnalogIn* FarbVoltage) { this->FarbVoltage= FarbVoltage; } int Farbsensor::read() { static int time=0; static float messungen=0.0f; if( time < 10 ){ messungen += FarbVoltage->read(); time++; return -1; } else{ float Ufarbsensor = messungen/10.0; Ufarbsensor = Ufarbsensor*3300;//Set the Voltage between 0mV und 3300mV pc1.printf("measure = %.0f mV\n", Ufarbsensor); messungen = 0.0f; time = 0; if ((Ufarbsensor > GREEN_DOWNLIMIT) && (Ufarbsensor < GREEN_UPLIMIT)) { return GREEN; } else if(Ufarbsensor < RED_UPLIMIT) { return RED; } else { return NOBLOCK; } } } Farbsensor::operator int() { return read(); }