Do NOT modify!

Dependencies:   mbed Servo ServoArm

Fork of PES_Yanick by zhaw_st16b_pes2_10

Committer:
beacon
Date:
Wed May 03 13:54:51 2017 +0000
Revision:
10:f76476943a6c
Parent:
4:67d7177c213f
Child:
12:c0bcb95885dd
oi

Who changed what in which revision?

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