Class Analog Sensor for ASAD.

Committer:
renemagrit
Date:
Mon Sep 09 13:24:45 2019 +0000
Revision:
0:ec0a410e0ce6
Class Sensor only for Analog Sensors.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
renemagrit 0:ec0a410e0ce6 1 #include <Sensor.h>
renemagrit 0:ec0a410e0ce6 2 Sensor::Sensor():n(0),k(0){
renemagrit 0:ec0a410e0ce6 3 pin=A0;
renemagrit 0:ec0a410e0ce6 4 }
renemagrit 0:ec0a410e0ce6 5 Sensor::Sensor(PinName _pin,float _n,float _k):n(_n),k(_k){
renemagrit 0:ec0a410e0ce6 6 //Iz nekog razoga se buni ako je u inicijalizatorskoj listi pa
renemagrit 0:ec0a410e0ce6 7 //MORA da se napise u telu konstruktora da bi radio
renemagrit 0:ec0a410e0ce6 8 pin=_pin;
renemagrit 0:ec0a410e0ce6 9 }
renemagrit 0:ec0a410e0ce6 10
renemagrit 0:ec0a410e0ce6 11 float Sensor::value(){
renemagrit 0:ec0a410e0ce6 12 AnalogIn ain(pin);
renemagrit 0:ec0a410e0ce6 13 return ain.read()*k+n;
renemagrit 0:ec0a410e0ce6 14 }