Oppgave 5.3
Dependencies: mbed
main.cpp
- Committer:
- Smashftw
- Date:
- 2017-10-03
- Revision:
- 0:76193024dd24
File content as of revision 0:76193024dd24:
#include "mbed.h" BusOut bargraph(p21, p22, p23, p24, p25, p26); float map(float x, float x1,float x2, float y1, float y2); AnalogIn ai(p20); Serial pc(USBTX,USBRX); volatile int y; int main() { while(1) { bargraph = (int) map(ai, 0.0, 1.0, 0.0, 33.0); wait (0.1); pc.printf ("Tallet er:%.1f\n", map(ai, 0.0, 1.0, 0.0, 33.0) ); } } float map(float x, float x1,float x2, float y1, float y2){ float y = y1 + (x - x1)* (y2-y1) / (x2 -x1); return y; }