Tester Electric
Dependencies: mbed
main.cpp@0:e35a2b1d9ff5, 2017-09-06 (annotated)
- Committer:
- adam_siwak
- Date:
- Wed Sep 06 14:24:26 2017 +0000
- Revision:
- 0:e35a2b1d9ff5
Tester Electric
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
adam_siwak | 0:e35a2b1d9ff5 | 1 | #include "mbed.h" |
adam_siwak | 0:e35a2b1d9ff5 | 2 | |
adam_siwak | 0:e35a2b1d9ff5 | 3 | //------------------------------------ |
adam_siwak | 0:e35a2b1d9ff5 | 4 | // Hyperterminal configuration |
adam_siwak | 0:e35a2b1d9ff5 | 5 | // 9600 bauds, 8-bit data, no parity |
adam_siwak | 0:e35a2b1d9ff5 | 6 | //------------------------------------ |
adam_siwak | 0:e35a2b1d9ff5 | 7 | |
adam_siwak | 0:e35a2b1d9ff5 | 8 | Serial pc(SERIAL_TX, SERIAL_RX); |
adam_siwak | 0:e35a2b1d9ff5 | 9 | |
adam_siwak | 0:e35a2b1d9ff5 | 10 | DigitalOut myled(LED1); |
adam_siwak | 0:e35a2b1d9ff5 | 11 | DigitalOut zas(PA_13); |
adam_siwak | 0:e35a2b1d9ff5 | 12 | |
adam_siwak | 0:e35a2b1d9ff5 | 13 | InterruptIn aparaty[10] = {PC_8, PC_6, PC_5, PA_12, PA_11, PB_12, PB_11, PB_2, PB_1, PB_15}; |
adam_siwak | 0:e35a2b1d9ff5 | 14 | |
adam_siwak | 0:e35a2b1d9ff5 | 15 | int licznik[10]; |
adam_siwak | 0:e35a2b1d9ff5 | 16 | |
adam_siwak | 0:e35a2b1d9ff5 | 17 | void trigger0() { licznik[0]++; } |
adam_siwak | 0:e35a2b1d9ff5 | 18 | void trigger1() { licznik[1]++; } |
adam_siwak | 0:e35a2b1d9ff5 | 19 | void trigger2() { licznik[2]++; } |
adam_siwak | 0:e35a2b1d9ff5 | 20 | void trigger3() { licznik[3]++; } |
adam_siwak | 0:e35a2b1d9ff5 | 21 | void trigger4() { licznik[4]++; } |
adam_siwak | 0:e35a2b1d9ff5 | 22 | void trigger5() { licznik[5]++; } |
adam_siwak | 0:e35a2b1d9ff5 | 23 | void trigger6() { licznik[6]++; } |
adam_siwak | 0:e35a2b1d9ff5 | 24 | void trigger7() { licznik[7]++; } |
adam_siwak | 0:e35a2b1d9ff5 | 25 | void trigger8() { licznik[8]++; } |
adam_siwak | 0:e35a2b1d9ff5 | 26 | void trigger9() { licznik[9]++; } |
adam_siwak | 0:e35a2b1d9ff5 | 27 | |
adam_siwak | 0:e35a2b1d9ff5 | 28 | int main() |
adam_siwak | 0:e35a2b1d9ff5 | 29 | { |
adam_siwak | 0:e35a2b1d9ff5 | 30 | int i; |
adam_siwak | 0:e35a2b1d9ff5 | 31 | |
adam_siwak | 0:e35a2b1d9ff5 | 32 | aparaty[0].rise(&trigger0); |
adam_siwak | 0:e35a2b1d9ff5 | 33 | aparaty[1].rise(&trigger1); |
adam_siwak | 0:e35a2b1d9ff5 | 34 | aparaty[2].rise(&trigger2); |
adam_siwak | 0:e35a2b1d9ff5 | 35 | aparaty[3].rise(&trigger3); |
adam_siwak | 0:e35a2b1d9ff5 | 36 | aparaty[4].rise(&trigger4); |
adam_siwak | 0:e35a2b1d9ff5 | 37 | aparaty[5].rise(&trigger5); |
adam_siwak | 0:e35a2b1d9ff5 | 38 | aparaty[6].rise(&trigger6); |
adam_siwak | 0:e35a2b1d9ff5 | 39 | aparaty[7].rise(&trigger7); |
adam_siwak | 0:e35a2b1d9ff5 | 40 | aparaty[8].rise(&trigger8); |
adam_siwak | 0:e35a2b1d9ff5 | 41 | aparaty[9].rise(&trigger9); |
adam_siwak | 0:e35a2b1d9ff5 | 42 | |
adam_siwak | 0:e35a2b1d9ff5 | 43 | while(1) { |
adam_siwak | 0:e35a2b1d9ff5 | 44 | if (zas == 0) { |
adam_siwak | 0:e35a2b1d9ff5 | 45 | for (i = 0; i < 10; i++) { |
adam_siwak | 0:e35a2b1d9ff5 | 46 | pc.printf("Aparat %i: %i\n\r", i+1, licznik[i]); |
adam_siwak | 0:e35a2b1d9ff5 | 47 | } |
adam_siwak | 0:e35a2b1d9ff5 | 48 | pc.printf("\n\r", i+1, licznik[i]); |
adam_siwak | 0:e35a2b1d9ff5 | 49 | for (i = 0; i < 10; i++) { |
adam_siwak | 0:e35a2b1d9ff5 | 50 | licznik[i] = 0; |
adam_siwak | 0:e35a2b1d9ff5 | 51 | } |
adam_siwak | 0:e35a2b1d9ff5 | 52 | } |
adam_siwak | 0:e35a2b1d9ff5 | 53 | zas = !zas; |
adam_siwak | 0:e35a2b1d9ff5 | 54 | myled = !myled; |
adam_siwak | 0:e35a2b1d9ff5 | 55 | wait(5); |
adam_siwak | 0:e35a2b1d9ff5 | 56 | } |
adam_siwak | 0:e35a2b1d9ff5 | 57 | } |