Oppgave 5.3
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:76193024dd24
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 03 11:40:12 2017 +0000 @@ -0,0 +1,21 @@ +#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; + } \ No newline at end of file