motor spins

Dependencies:   mbed

Fork of analoghalls5 by Bayley Wang

throttle.cpp

Committer:
nki
Date:
2015-03-04
Revision:
6:99ee0ce47fb2
Parent:
1:1f58bdcf2956

File content as of revision 6:99ee0ce47fb2:

#include "includes.h"
#include "sensors.h"

Throttle::Throttle(PinName pin, float min, float max) {
    _in = new AnalogVoltageSensor(pin, 1.0f);
    _min = min;
    _max = max;
}

float Throttle::GetThrottle() {
    float v = _in->GetVoltage();
    return (v - _min) / (_max - _min);
}