Do NOT modify!

Dependencies:   mbed Servo ServoArm

Fork of PES_Yanick by zhaw_st16b_pes2_10

Committer:
beacon
Date:
Wed May 10 13:30:13 2017 +0000
Revision:
12:c0bcb95885dd
Parent:
10:f76476943a6c
k

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 12:c0bcb95885dd 21 static int time=0;
beacon 12:c0bcb95885dd 22 static float Messungen=0.0f;
beacon 12:c0bcb95885dd 23 if( time < 10 ){
beacon 12:c0bcb95885dd 24 Messungen += FarbVoltage->read();
beacon 12:c0bcb95885dd 25 time++;
beacon 12:c0bcb95885dd 26 return -1;
beacon 12:c0bcb95885dd 27 }
beacon 12:c0bcb95885dd 28 else{
beacon 12:c0bcb95885dd 29 time = 0;
beacon 12:c0bcb95885dd 30 float Ufarbsensor = Messungen/10.0;
beacon 12:c0bcb95885dd 31 Ufarbsensor = Ufarbsensor*3300; //Set the Voltage between 0mV und 3300mV
beacon 12:c0bcb95885dd 32
beacon 12:c0bcb95885dd 33 if ((Ufarbsensor > GREEN_DOWNLIMIT) && (Ufarbsensor < GREEN_UPLIMIT))
beacon 12:c0bcb95885dd 34 {
beacon 12:c0bcb95885dd 35 return GREEN;
beacon 12:c0bcb95885dd 36 }
beacon 12:c0bcb95885dd 37 else if(Ufarbsensor < RED_UPLIMIT)
beacon 12:c0bcb95885dd 38 {
beacon 12:c0bcb95885dd 39 return RED;
beacon 12:c0bcb95885dd 40 }
beacon 12:c0bcb95885dd 41 else
beacon 12:c0bcb95885dd 42 {
beacon 12:c0bcb95885dd 43 return NOBLOCK;
beacon 12:c0bcb95885dd 44 }
beacon 1:388c915756f5 45 }
beacon 1:388c915756f5 46 }
beacon 1:388c915756f5 47
beacon 1:388c915756f5 48 Farbsensor::operator int()
beacon 1:388c915756f5 49 {
beacon 1:388c915756f5 50 return read();
beacon 1:388c915756f5 51 }