Oppgave 5.3

Dependencies:   mbed

Committer:
Smashftw
Date:
Tue Oct 03 11:40:12 2017 +0000
Revision:
0:76193024dd24
Oppgave 5.3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Smashftw 0:76193024dd24 1 #include "mbed.h"
Smashftw 0:76193024dd24 2
Smashftw 0:76193024dd24 3
Smashftw 0:76193024dd24 4 BusOut bargraph(p21, p22, p23, p24, p25, p26);
Smashftw 0:76193024dd24 5 float map(float x, float x1,float x2, float y1, float y2);
Smashftw 0:76193024dd24 6 AnalogIn ai(p20);
Smashftw 0:76193024dd24 7 Serial pc(USBTX,USBRX);
Smashftw 0:76193024dd24 8 volatile int y;
Smashftw 0:76193024dd24 9
Smashftw 0:76193024dd24 10 int main() {
Smashftw 0:76193024dd24 11 while(1) {
Smashftw 0:76193024dd24 12 bargraph = (int) map(ai, 0.0, 1.0, 0.0, 33.0);
Smashftw 0:76193024dd24 13 wait (0.1);
Smashftw 0:76193024dd24 14 pc.printf ("Tallet er:%.1f\n", map(ai, 0.0, 1.0, 0.0, 33.0) );
Smashftw 0:76193024dd24 15
Smashftw 0:76193024dd24 16 }
Smashftw 0:76193024dd24 17 }
Smashftw 0:76193024dd24 18 float map(float x, float x1,float x2, float y1, float y2){
Smashftw 0:76193024dd24 19 float y = y1 + (x - x1)* (y2-y1) / (x2 -x1);
Smashftw 0:76193024dd24 20 return y;
Smashftw 0:76193024dd24 21 }