0% found this document useful (0 votes)
6 views6 pages

Seven Segment Display Control Code

The document contains C code for controlling seven-segment displays based on input from switches. It defines multiple functions to set the display states and a main loop that checks the switch states to determine which pattern to display. Additionally, there are comments indicating how to modify the code to display specific characters or identifiers on the segments.

Uploaded by

Lulu Khoirun
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views6 pages

Seven Segment Display Control Code

The document contains C code for controlling seven-segment displays based on input from switches. It defines multiple functions to set the display states and a main loop that checks the switch states to determine which pattern to display. Additionally, there are comments indicating how to modify the code to display specific characters or identifiers on the segments.

Uploaded by

Lulu Khoirun
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

#include "io.

h"

#include "system.h"

unsigned int seg0[4] = {0x00, 0x00, 0x00, 0x00};

unsigned int seg1[4] = {0x00, 0x00, 0x00, 0x00};

unsigned int seg2[4] = {0x00, 0x00, 0x00, 0x00};

unsigned int seg3[4] = {0x00, 0x00, 0x00, 0x00};

unsigned int seg4[4] = {0x00, 0x00, 0x00, 0x00};

unsigned int seg5[4] = {0x00, 0x00, 0x00, 0x00};

unsigned int seg6[4] = {0x00, 0x00, 0x00, 0x00};

void set0(unsigned int seg0, unsigned int seg1, unsigned int seg2, unsigned int seg3,

unsigned int seg4, unsigned int seg5, unsigned int seg6)

IOWR(0x9030, 0, seg0);

IOWR(0x9031, 1, seg1);

IOWR(0x9032, 2, seg2);

IOWR(0x9033, 3, seg3);

IOWR(0x9034, 4, seg4);

IOWR(0x9035, 5, seg5);

IOWR(0x9036, 6, seg6);

void set1(unsigned int seg0, unsigned int seg1, unsigned int seg2, unsigned int seg3,

unsigned int seg4, unsigned int seg5, unsigned int seg6)


{

IOWR(0x9020, 0, seg0);

IOWR(0x9021, 1, seg1);

IOWR(0x9022, 2, seg2);

IOWR(0x9023, 3, seg3);

IOWR(0x9024, 4, seg4);

IOWR(0x9025, 5, seg5);

IOWR(0x9026, 6, seg6);

void set2(unsigned int seg0, unsigned int seg1, unsigned int seg2, unsigned int seg3,

unsigned int seg4, unsigned int seg5, unsigned int seg6)

IOWR(0x9010, 0, seg0);

IOWR(0x9011, 1, seg1);

IOWR(0x9012, 2, seg2);

IOWR(0x9013, 3, seg3);

IOWR(0x9014, 4, seg4);

IOWR(0x9015, 5, seg5);

IOWR(0x9016, 6, seg6);

void set3(unsigned int seg0, unsigned int seg1, unsigned int seg2, unsigned int seg3,

unsigned int seg4, unsigned int seg5, unsigned int seg6)

{
IOWR(0x9000, 0, seg0);

IOWR(0x9001, 1, seg1);

IOWR(0x9002, 2, seg2);

IOWR(0x9003, 3, seg3);

IOWR(0x9004, 4, seg4);

IOWR(0x9005, 5, seg5);

IOWR(0x9006, 6, seg6);

int main()

unsigned int sw1 = IORD(0x9040, 0);

unsigned int sw2 = IORD(0x9041, 1);

unsigned int sw3 = IORD(0x9042, 2);

unsigned int sw4 = IORD(0x9043, 3);

unsigned int sw5 = IORD(0x9044, 4);

unsigned int sw6 = IORD(0x9045, 5);

unsigned int sw7 = IORD(0x9046, 6);

unsigned int sw8 = IORD(0x9047, 7);

while(1){

if(sw1 == 1 && sw2 == 1 && sw3 == 1 && sw4 == 0 &&

sw5 == 0 && sw6 == 0 && sw7 == 0 && sw8 == 0)

set0(0x99, 0x99, 0x99, 0x00, 0x99, 0x99, 0x00);


set1(0x99, 0x99, 0x99, 0x00, 0x99, 0x99, 0x00);

set2(0x99, 0x00, 0x00, 0x99, 0x99, 0x99, 0x99);

set3(0x00, 0x00, 0x00, 0x00, 0x99, 0x99, 0x00);

else if (sw1 == 0 && sw2 == 0 && sw3 == 0 && sw4 == 0 &&

sw5 == 0 && sw6 == 1 && sw7 == 1 && sw8 == 1)

set0(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);

set1(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);

set2(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);

set3(0x00, 0x99, 0x99, 0x00, 0x00, 0x00, 0x00);

return 0;

}
KETERANGAN:

Yang warna kuning di sesuaikan sama kolom base

Void0 = base dari segmen 1/output 1

Void1 = base dari segmen 2/output 2, dst.

Kalo yg int main= base switcher/input

WARNA HIJAU

Untuk koding biar muncul nama di seven segmen, kalo punyaku ketika switch 1,2,3 di
nyalakan di seven segmen muncul huruf namaku (MEI)

Maksud (0x00) = led di seven segmen mati, (0x99) = led di seven segmen nyala

WARNA UNGU

Koding biar muncul NRP di seven segmen


Urutan seven segmen

You might also like