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@6:ba26dd3251b3, 2017-04-26 (annotated)
- Committer:
- beacon
- Date:
- Wed Apr 26 14:09:08 2017 +0000
- Revision:
- 6:ba26dd3251b3
- Parent:
- 4:67d7177c213f
- Child:
- 10:f76476943a6c
YESSS! On time!!
Who changed what in which revision?
| User | Revision | Line number | New 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 | 1:388c915756f5 | 21 | int farbe; |
| beacon | 1:388c915756f5 | 22 | float Ufarbsensor=FarbVoltage->read(); |
| beacon | 1:388c915756f5 | 23 | Ufarbsensor=Ufarbsensor*3300; //Set the Voltage between 0mV und 3300mV |
| beacon | 1:388c915756f5 | 24 | |
| beacon | 1:388c915756f5 | 25 | if ((Ufarbsensor > GREEN_DOWNLIMIT) && (Ufarbsensor < GREEN_UPLIMIT)) |
| beacon | 1:388c915756f5 | 26 | { |
| beacon | 1:388c915756f5 | 27 | farbe=1; |
| beacon | 1:388c915756f5 | 28 | } |
| beacon | 1:388c915756f5 | 29 | else if(Ufarbsensor < RED_UPLIMIT) |
| beacon | 1:388c915756f5 | 30 | { |
| beacon | 1:388c915756f5 | 31 | farbe=-1; |
| beacon | 1:388c915756f5 | 32 | } |
| beacon | 1:388c915756f5 | 33 | else |
| beacon | 1:388c915756f5 | 34 | { |
| beacon | 1:388c915756f5 | 35 | farbe=0; |
| beacon | 1:388c915756f5 | 36 | } |
| beacon | 1:388c915756f5 | 37 | return farbe; |
| beacon | 1:388c915756f5 | 38 | } |
| beacon | 1:388c915756f5 | 39 | |
| beacon | 1:388c915756f5 | 40 | Farbsensor::operator int() |
| beacon | 1:388c915756f5 | 41 | { |
| beacon | 1:388c915756f5 | 42 | return read(); |
| beacon | 1:388c915756f5 | 43 | } |
