Antonia Baumgartner / Mbed 2 deprecated YB_copy

Dependencies:   mbed

Fork of Versuch21 by Antonia Baumgartner

Committer:
baumgant
Date:
Wed Apr 25 11:16:16 2018 +0000
Revision:
2:efa9a78591da
Parent:
1:6ef5bc60e69c
Child:
3:f44ef28cfb2d
PES2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
baumgant 0:b886f13e4ac6 1 #include <cmath>
baumgant 0:b886f13e4ac6 2 #include "IRSensorGF.h"
baumgant 0:b886f13e4ac6 3
baumgant 2:efa9a78591da 4 //------------------------------------------------------------------------------
baumgant 2:efa9a78591da 5
baumgant 0:b886f13e4ac6 6 using namespace std;
baumgant 0:b886f13e4ac6 7
mrbb2 1:6ef5bc60e69c 8 IRSensorGF::IRSensorGF(AnalogIn& distance):
mrbb2 1:6ef5bc60e69c 9
mrbb2 1:6ef5bc60e69c 10 distance(distance)
mrbb2 1:6ef5bc60e69c 11 {
mrbb2 1:6ef5bc60e69c 12
mrbb2 1:6ef5bc60e69c 13
mrbb2 1:6ef5bc60e69c 14 }
mrbb2 1:6ef5bc60e69c 15
mrbb2 1:6ef5bc60e69c 16 IRSensorGF::~IRSensorGF() {}
baumgant 0:b886f13e4ac6 17
baumgant 2:efa9a78591da 18 //------------------------------------------------------------------------------
baumgant 2:efa9a78591da 19
mrbb2 1:6ef5bc60e69c 20 int IRSensorGF::read()
mrbb2 1:6ef5bc60e69c 21 {
mrbb2 1:6ef5bc60e69c 22 int d;
baumgant 0:b886f13e4ac6 23
mrbb2 1:6ef5bc60e69c 24 /*if (3300*(distance)>2900){ //5-6cm
mrbb2 1:6ef5bc60e69c 25 d=1;
mrbb2 1:6ef5bc60e69c 26 }
mrbb2 1:6ef5bc60e69c 27 else{
mrbb2 1:6ef5bc60e69c 28 d=0;
mrbb2 1:6ef5bc60e69c 29 }*/
mrbb2 1:6ef5bc60e69c 30
mrbb2 1:6ef5bc60e69c 31 int w = 10/(distance)*exp(1.4481);
mrbb2 1:6ef5bc60e69c 32
mrbb2 1:6ef5bc60e69c 33 if (w < 60) {
baumgant 0:b886f13e4ac6 34 d=1;
baumgant 2:efa9a78591da 35 } else {
baumgant 0:b886f13e4ac6 36 d=0;
baumgant 2:efa9a78591da 37 }
mrbb2 1:6ef5bc60e69c 38
baumgant 2:efa9a78591da 39 return d;
mrbb2 1:6ef5bc60e69c 40
baumgant 2:efa9a78591da 41 }