Babić Mirhat Hasanic Nadin

Dependencies:   mbed

Fork of LV4-GRUPA2-Tim004 by tim004 tim004

Committer:
tim004
Date:
Mon Mar 24 10:52:40 2014 +0000
Revision:
1:b81cedb4e2c9
Parent:
0:ec52fc690f15
LV4-GRUPA2-Tim004

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tim004 0:ec52fc690f15 1 #include "mbed.h"
tim004 1:b81cedb4e2c9 2
tim004 1:b81cedb4e2c9 3 using namespace std;
tim004 1:b81cedb4e2c9 4
tim004 1:b81cedb4e2c9 5 BusOut segments(dp26, dp27, dp5, dp6, dp28, dp1, dp2);
tim004 1:b81cedb4e2c9 6 BusOut digit(dp23, dp24, dp25);
tim004 1:b81cedb4e2c9 7 DigitalOut point(dp4);
tim004 1:b81cedb4e2c9 8 AnalogIn napon(dp9);
tim004 1:b81cedb4e2c9 9
tim004 1:b81cedb4e2c9 10 Timer count;
tim004 1:b81cedb4e2c9 11
tim004 1:b81cedb4e2c9 12 int codes[10] = {0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x078,0x0,0x10};
tim004 1:b81cedb4e2c9 13
tim004 1:b81cedb4e2c9 14
tim004 0:ec52fc690f15 15
tim004 1:b81cedb4e2c9 16 void display(float time) {
tim004 1:b81cedb4e2c9 17 time *= 10;
tim004 0:ec52fc690f15 18
tim004 1:b81cedb4e2c9 19 int numbers[3] = { (int)(time / 10.) % 10, (int)(time) % 10,
tim004 1:b81cedb4e2c9 20 (int)(time * 10.) % 10 };
tim004 0:ec52fc690f15 21
tim004 1:b81cedb4e2c9 22 segments = codes[ numbers[2]];
tim004 1:b81cedb4e2c9 23 digit = 3;
tim004 0:ec52fc690f15 24
tim004 1:b81cedb4e2c9 25 wait_ms(2);
tim004 1:b81cedb4e2c9 26
tim004 1:b81cedb4e2c9 27 digit = 7;
tim004 1:b81cedb4e2c9 28
tim004 1:b81cedb4e2c9 29 segments = codes[ numbers[1]];
tim004 1:b81cedb4e2c9 30 digit = 5;
tim004 0:ec52fc690f15 31
tim004 0:ec52fc690f15 32 point = 1;
tim004 1:b81cedb4e2c9 33 wait_ms(2);
tim004 1:b81cedb4e2c9 34
tim004 1:b81cedb4e2c9 35 digit = 7;
tim004 1:b81cedb4e2c9 36
tim004 1:b81cedb4e2c9 37 segments = codes[ numbers[0]];
tim004 1:b81cedb4e2c9 38 digit = 6;
tim004 1:b81cedb4e2c9 39
tim004 1:b81cedb4e2c9 40 point = 0;
tim004 1:b81cedb4e2c9 41
tim004 1:b81cedb4e2c9 42 wait_ms(2);
tim004 1:b81cedb4e2c9 43
tim004 1:b81cedb4e2c9 44 digit = 7;
tim004 1:b81cedb4e2c9 45
tim004 1:b81cedb4e2c9 46
tim004 1:b81cedb4e2c9 47 segments = 7;
tim004 0:ec52fc690f15 48 point = 1;
tim004 0:ec52fc690f15 49 }
tim004 1:b81cedb4e2c9 50
tim004 1:b81cedb4e2c9 51 int main() {
tim004 1:b81cedb4e2c9 52
tim004 1:b81cedb4e2c9 53 float last = 0;
tim004 1:b81cedb4e2c9 54 while(true) {
tim004 1:b81cedb4e2c9 55 float suma = 0;
tim004 1:b81cedb4e2c9 56 for(int i = 0; i < 50; i++){
tim004 1:b81cedb4e2c9 57 display(last * 3.3);
tim004 1:b81cedb4e2c9 58 suma += napon;
tim004 1:b81cedb4e2c9 59 }
tim004 1:b81cedb4e2c9 60
tim004 1:b81cedb4e2c9 61 last = suma / 50;
tim004 1:b81cedb4e2c9 62 }
tim004 0:ec52fc690f15 63
tim004 0:ec52fc690f15 64
tim004 0:ec52fc690f15 65 }