Sverre Didrichsen
/
Oving5-3A
Martin
main.cpp
- Committer:
- mdidrich
- Date:
- 2017-09-26
- Revision:
- 0:78d9e6f47c28
File content as of revision 0:78d9e6f47c28:
#include "mbed.h" BusOut bargraph(p21, p22, p23, p24, p25, p26); AnalogIn ai(p20); float map(float x, float x1, float x2, float y1, float y2); int main() { while (1) { bargraph = (int) map(ai, 0.0, 1.0, 0.0, 33.0); wait(0.1); } } float map(float x, float x1, float x2, float y1, float y2){ float y; y = ( y1 + (x - x1)*((y2-y1)/(x2-x1))); return y; }