Do NOT modify!

Dependencies:   mbed Servo ServoArm

Fork of PES_Yanick by zhaw_st16b_pes2_10

Committer:
beacon
Date:
Tue May 02 08:39:35 2017 +0000
Revision:
9:ac362674c480
kl

Who changed what in which revision?

UserRevisionLine numberNew contents of line
beacon 9:ac362674c480 1 #include "Robot.h"
beacon 9:ac362674c480 2 #include "Declarations.h"
beacon 9:ac362674c480 3
beacon 9:ac362674c480 4
beacon 9:ac362674c480 5 Farbsensor::Farbsensor()
beacon 9:ac362674c480 6 {
beacon 9:ac362674c480 7 }
beacon 9:ac362674c480 8
beacon 9:ac362674c480 9 Farbsensor::Farbsensor(AnalogIn* FarbVoltage)
beacon 9:ac362674c480 10 {
beacon 9:ac362674c480 11 init(FarbVoltage);
beacon 9:ac362674c480 12 }
beacon 9:ac362674c480 13
beacon 9:ac362674c480 14 void Farbsensor::init(AnalogIn* FarbVoltage)
beacon 9:ac362674c480 15 {
beacon 9:ac362674c480 16 this->FarbVoltage= FarbVoltage;
beacon 9:ac362674c480 17 }
beacon 9:ac362674c480 18
beacon 9:ac362674c480 19 int Farbsensor::read()
beacon 9:ac362674c480 20 {
beacon 9:ac362674c480 21 int farbe;
beacon 9:ac362674c480 22 float Ufarbsensor=FarbVoltage->read();
beacon 9:ac362674c480 23 Ufarbsensor=Ufarbsensor*3300; //Set the Voltage between 0mV und 3300mV
beacon 9:ac362674c480 24
beacon 9:ac362674c480 25 if ((Ufarbsensor > GREEN_DOWNLIMIT) && (Ufarbsensor < GREEN_UPLIMIT))
beacon 9:ac362674c480 26 {
beacon 9:ac362674c480 27 farbe=1;
beacon 9:ac362674c480 28 }
beacon 9:ac362674c480 29 else if(Ufarbsensor < RED_UPLIMIT)
beacon 9:ac362674c480 30 {
beacon 9:ac362674c480 31 farbe=-1;
beacon 9:ac362674c480 32 }
beacon 9:ac362674c480 33 else
beacon 9:ac362674c480 34 {
beacon 9:ac362674c480 35 farbe=0;
beacon 9:ac362674c480 36 }
beacon 9:ac362674c480 37 return farbe;
beacon 9:ac362674c480 38 }
beacon 9:ac362674c480 39
beacon 9:ac362674c480 40 Farbsensor::operator int()
beacon 9:ac362674c480 41 {
beacon 9:ac362674c480 42 return read();
beacon 9:ac362674c480 43 }