Simulacija rada semafora s 4 LED diode, 7 segmentog display-a, zvučnika, tipkala i potenciometra

Dependencies:   mbed

https://os.mbed.com/media/uploads/dcindric/picture1.png

segmentni.cpp

Committer:
dcindric
Date:
2021-05-07
Revision:
1:1b7ec94fe4ab
Parent:
0:2531c2b824f9

File content as of revision 1:1b7ec94fe4ab:

// SegDisplay.cpp file for Exercise 7-7
#include "segmentni.h"

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
Serial pc2(USBTX, USBRX);

void SegConvert(int SegValue)   // function 'SegConvert'
{
    char SegByte;
    switch (SegValue) { //DP G F E D C B A
        case 0 :
            pc2.printf("0 \n \r");
            SegByte = 0x3F;
            break; // 0 0 1 1 1 1 1 1 binary
        case 1 :
            pc2.printf("1 \n \r");
            SegByte = 0x06;
            break; // 0 0 0 0 0 1 1 0 binary
        case 2 :
            pc2.printf("2 \n \r");
            SegByte = 0x5B;
            break; // 0 1 0 1 1 0 1 1 binary
        case 3 :
            pc2.printf("3 \n \r");
            SegByte = 0x4F;
            break; // 0 1 0 0 1 1 1 1 binary
        case 4 :
            pc2.printf("4 \n \r");
            SegByte = 0x66;
            break; // 0 1 1 0 0 1 1 0 binary
        case 5 :
            pc2.printf("5 \n \r");
            SegByte = 0x6D;
            break; // 0 1 1 0 1 1 0 1 binary
        case 6 :
            pc2.printf("6 \n \r");
            SegByte = 0x7D;
            break; // 0 1 1 1 1 1 0 1 binary
        case 7 :
            pc2.printf("7 \n \r");
            SegByte = 0x07;
            break; // 0 0 0 0 0 1 1 1 binary
        case 8 :
            pc2.printf("8 \n \r");
            SegByte = 0x7F;
            break; // 0 1 1 1 1 1 1 1 binary
        case 9 :
            pc2.printf("9 \n \r");
            SegByte = 0x6F;
            break; // 0 1 1 0 1 1 1 1 binary
        case 10:
            SegByte = 0x21;
            break; // 0 0 1 0 0 0 0 1 binary
        case 11:
            SegByte = 0x80;
            break; // 1 0 0 0 0 0 0 0 binary
    }
    Seg = SegByte;
}