Oppgave6.3

Dependencies:   mbed

Committer:
Smashftw
Date:
Tue Oct 03 14:22:25 2017 +0000
Revision:
0:e6f472233de6
Oppgave63

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Smashftw 0:e6f472233de6 1 #include "mbed.h"
Smashftw 0:e6f472233de6 2
Smashftw 0:e6f472233de6 3 BusOut ledNS (p7, p6, p5); // Grønn, Gul, Rød
Smashftw 0:e6f472233de6 4 BusOut ledOV (p10, p9, p8); // Grønn, Gul, Rød
Smashftw 0:e6f472233de6 5 DigitalIn bryter(p20);
Smashftw 0:e6f472233de6 6 Ticker t1;
Smashftw 0:e6f472233de6 7 volatile int T2;
Smashftw 0:e6f472233de6 8 int lysNS[8] = {1, 1, 1, 3, 4, 2, 1, 1};
Smashftw 0:e6f472233de6 9 int lysOV[8] = {4, 2, 1, 1, 1, 1 ,1, 3};
Smashftw 0:e6f472233de6 10 int ventetid[8] = {5000, 2000, 1000, 500, 5000, 2000, 1000, 500};
Smashftw 0:e6f472233de6 11 void f (void);
Smashftw 0:e6f472233de6 12
Smashftw 0:e6f472233de6 13 int main()
Smashftw 0:e6f472233de6 14 {
Smashftw 0:e6f472233de6 15 while(1) {
Smashftw 0:e6f472233de6 16 t1.attach (&f,1);
Smashftw 0:e6f472233de6 17 if (T2<20) {
Smashftw 0:e6f472233de6 18
Smashftw 0:e6f472233de6 19 for (int i=0; i<8; i++) {
Smashftw 0:e6f472233de6 20
Smashftw 0:e6f472233de6 21 ledNS = lysNS[i];
Smashftw 0:e6f472233de6 22 ledOV = lysOV[i];
Smashftw 0:e6f472233de6 23 wait_ms (ventetid[i]);
Smashftw 0:e6f472233de6 24 }
Smashftw 0:e6f472233de6 25 } else if (T2 >= 20) {
Smashftw 0:e6f472233de6 26
Smashftw 0:e6f472233de6 27 ledNS=lysNS [5];
Smashftw 0:e6f472233de6 28 ledOV=lysOV [1];
Smashftw 0:e6f472233de6 29 wait(0.5);
Smashftw 0:e6f472233de6 30 ledNS=0;
Smashftw 0:e6f472233de6 31 ledOV=0;
Smashftw 0:e6f472233de6 32 wait(0.5);
Smashftw 0:e6f472233de6 33 }
Smashftw 0:e6f472233de6 34 }
Smashftw 0:e6f472233de6 35 }
Smashftw 0:e6f472233de6 36 void f (void)
Smashftw 0:e6f472233de6 37 {
Smashftw 0:e6f472233de6 38 if ( T2<40) {
Smashftw 0:e6f472233de6 39 T2++;
Smashftw 0:e6f472233de6 40 } else T2 = 0;
Smashftw 0:e6f472233de6 41
Smashftw 0:e6f472233de6 42
Smashftw 0:e6f472233de6 43
Smashftw 0:e6f472233de6 44
Smashftw 0:e6f472233de6 45
Smashftw 0:e6f472233de6 46 }
Smashftw 0:e6f472233de6 47