arben sutter
Dependencies: mbed
Fork of Oppgave7_1 by
Revision 7:cd3eaa4ef912, committed 2017-10-17
- Comitter:
- olemh88
- Date:
- Tue Oct 17 12:56:39 2017 +0000
- Parent:
- 6:7c9aad508bf2
- Commit message:
- Oppgave 7_3;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 7c9aad508bf2 -r cd3eaa4ef912 main.cpp --- a/main.cpp Tue Oct 17 11:41:48 2017 +0000 +++ b/main.cpp Tue Oct 17 12:56:39 2017 +0000 @@ -6,6 +6,9 @@ DigitalOut Led3(LED3); DigitalOut Led4(LED4); DigitalIn bryter(p20); +Serial pc(USBTX, USBRX); + +int svar; Timer t1; BusOut bargraph(p21, p22, p23, p24, p25, p26); @@ -17,7 +20,11 @@ int main() { srand(noiseValue(1, 1000)); + pc.printf ("hvem er raskest av ole, Andreas og Arben\n"); + pc.printf("LED1,2 og 3 vill lyse for Led4 lyser og du trykker \n"); while(1) { + int start = 0; + t2.start(); int tid = 0; Led1 = 1; wait(1); @@ -29,20 +36,41 @@ Led1 = 0; Led2 = 0; Led3 = 0; + t1.stop(); + start = t2.read(); + pc.printf("Tiden som har gatt til timeren starter: "); + pc.printf("%d", start); + if(bryter == 1) { + pc.printf("Na juksa du"); + } t1.start(); while(bryter == 0) { wait_ms(1); } - + t1.stop(); tid = t1.read_ms(); - bargraph = tid / 10; + pc.printf ("\n din tid ble: "); + pc.printf ("%d", tid); + if(tid < 20) { + pc.printf("Veldig bra"); + } + if (tid == (20 > 50)) { + pc.printf("Bra"); + } + if(tid == (50 > 100)) { + pc.printf("Treigt"); + } + if(tid > 100) { + pc.printf("Haha, du sutter"); + } } } + int noiseValue(int low, int high) { uint16_t reading, rnd;