![](/media/cache/group/tvz-logo.png.50x50_q85.png)
Simulacija rada semafora s 4 LED diode, 7 segmentog display-a, zvučnika, tipkala i potenciometra
Dependencies: mbed
segmentni.cpp@1:1b7ec94fe4ab, 2021-05-07 (annotated)
- Committer:
- dcindric
- Date:
- Fri May 07 10:33:28 2021 +0000
- Revision:
- 1:1b7ec94fe4ab
- Parent:
- 0:2531c2b824f9
Konstukcijski Cindric
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dcindric | 0:2531c2b824f9 | 1 | // SegDisplay.cpp file for Exercise 7-7 |
dcindric | 0:2531c2b824f9 | 2 | #include "segmentni.h" |
dcindric | 0:2531c2b824f9 | 3 | |
dcindric | 0:2531c2b824f9 | 4 | BusOut Seg(PB_1, PB_2, PB_3, PB_4, PB_5, PB_13, PB_14, PB_15); // A,B,C,D,E,F,G,DP |
dcindric | 0:2531c2b824f9 | 5 | Serial pc2(USBTX, USBRX); |
dcindric | 0:2531c2b824f9 | 6 | |
dcindric | 0:2531c2b824f9 | 7 | void SegConvert(int SegValue) // function 'SegConvert' |
dcindric | 0:2531c2b824f9 | 8 | { |
dcindric | 0:2531c2b824f9 | 9 | char SegByte; |
dcindric | 0:2531c2b824f9 | 10 | switch (SegValue) { //DP G F E D C B A |
dcindric | 0:2531c2b824f9 | 11 | case 0 : |
dcindric | 0:2531c2b824f9 | 12 | pc2.printf("0 \n \r"); |
dcindric | 0:2531c2b824f9 | 13 | SegByte = 0x3F; |
dcindric | 0:2531c2b824f9 | 14 | break; // 0 0 1 1 1 1 1 1 binary |
dcindric | 0:2531c2b824f9 | 15 | case 1 : |
dcindric | 0:2531c2b824f9 | 16 | pc2.printf("1 \n \r"); |
dcindric | 0:2531c2b824f9 | 17 | SegByte = 0x06; |
dcindric | 0:2531c2b824f9 | 18 | break; // 0 0 0 0 0 1 1 0 binary |
dcindric | 0:2531c2b824f9 | 19 | case 2 : |
dcindric | 0:2531c2b824f9 | 20 | pc2.printf("2 \n \r"); |
dcindric | 0:2531c2b824f9 | 21 | SegByte = 0x5B; |
dcindric | 0:2531c2b824f9 | 22 | break; // 0 1 0 1 1 0 1 1 binary |
dcindric | 0:2531c2b824f9 | 23 | case 3 : |
dcindric | 0:2531c2b824f9 | 24 | pc2.printf("3 \n \r"); |
dcindric | 0:2531c2b824f9 | 25 | SegByte = 0x4F; |
dcindric | 0:2531c2b824f9 | 26 | break; // 0 1 0 0 1 1 1 1 binary |
dcindric | 0:2531c2b824f9 | 27 | case 4 : |
dcindric | 0:2531c2b824f9 | 28 | pc2.printf("4 \n \r"); |
dcindric | 0:2531c2b824f9 | 29 | SegByte = 0x66; |
dcindric | 0:2531c2b824f9 | 30 | break; // 0 1 1 0 0 1 1 0 binary |
dcindric | 0:2531c2b824f9 | 31 | case 5 : |
dcindric | 0:2531c2b824f9 | 32 | pc2.printf("5 \n \r"); |
dcindric | 0:2531c2b824f9 | 33 | SegByte = 0x6D; |
dcindric | 0:2531c2b824f9 | 34 | break; // 0 1 1 0 1 1 0 1 binary |
dcindric | 0:2531c2b824f9 | 35 | case 6 : |
dcindric | 0:2531c2b824f9 | 36 | pc2.printf("6 \n \r"); |
dcindric | 0:2531c2b824f9 | 37 | SegByte = 0x7D; |
dcindric | 0:2531c2b824f9 | 38 | break; // 0 1 1 1 1 1 0 1 binary |
dcindric | 0:2531c2b824f9 | 39 | case 7 : |
dcindric | 0:2531c2b824f9 | 40 | pc2.printf("7 \n \r"); |
dcindric | 0:2531c2b824f9 | 41 | SegByte = 0x07; |
dcindric | 0:2531c2b824f9 | 42 | break; // 0 0 0 0 0 1 1 1 binary |
dcindric | 0:2531c2b824f9 | 43 | case 8 : |
dcindric | 0:2531c2b824f9 | 44 | pc2.printf("8 \n \r"); |
dcindric | 0:2531c2b824f9 | 45 | SegByte = 0x7F; |
dcindric | 0:2531c2b824f9 | 46 | break; // 0 1 1 1 1 1 1 1 binary |
dcindric | 0:2531c2b824f9 | 47 | case 9 : |
dcindric | 0:2531c2b824f9 | 48 | pc2.printf("9 \n \r"); |
dcindric | 0:2531c2b824f9 | 49 | SegByte = 0x6F; |
dcindric | 0:2531c2b824f9 | 50 | break; // 0 1 1 0 1 1 1 1 binary |
dcindric | 0:2531c2b824f9 | 51 | case 10: |
dcindric | 0:2531c2b824f9 | 52 | SegByte = 0x21; |
dcindric | 0:2531c2b824f9 | 53 | break; // 0 0 1 0 0 0 0 1 binary |
dcindric | 0:2531c2b824f9 | 54 | case 11: |
dcindric | 0:2531c2b824f9 | 55 | SegByte = 0x80; |
dcindric | 0:2531c2b824f9 | 56 | break; // 1 0 0 0 0 0 0 0 binary |
dcindric | 0:2531c2b824f9 | 57 | } |
dcindric | 0:2531c2b824f9 | 58 | Seg = SegByte; |
dcindric | 0:2531c2b824f9 | 59 | } |
dcindric | 0:2531c2b824f9 | 60 |