0% found this document useful (0 votes)
6 views

7-Segment Code-5000

The document contains code for controlling a 7-segment display using Arduino. It defines segment values for displaying numbers 0 to 9 and includes functions to set up the display and loop through the numbers with a one-second delay. The code utilizes digitalWrite and pinMode functions to manage the output pins for the display segments.

Uploaded by

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

7-Segment Code-5000

The document contains code for controlling a 7-segment display using Arduino. It defines segment values for displaying numbers 0 to 9 and includes functions to set up the display and loop through the numbers with a one-second delay. The code utilizes digitalWrite and pinMode functions to manage the output pins for the display segments.

Uploaded by

Ahmed Abolabn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

unsigned const int A = 13;

unsigned const int B = 12;

unsigned const int C = 11;

unsigned const int D = 10;

unsigned const int E = 9;

unsigned const int F = 8;

unsigned const int G = 7;

unsigned const int H = 6;

// Define segment values for each number

const int SEGMENTS[10][7] = {

{1, 1, 1, 1, 1, 1, 0}, // 0

{0, 1, 1, 0, 0, 0, 0}, // 1

{1, 1, 0, 1, 1, 0, 1}, // 2

{1, 1, 1, 1, 0, 0, 1}, // 3

{0, 1, 1, 0, 0, 1, 1}, // 4

{1, 0, 1, 1, 0, 1, 1}, // 5

{1, 0, 1, 1, 1, 1, 1}, // 6

{1, 1, 1, 0, 0, 0, 0}, // 7

{1, 1, 1, 1, 1, 1, 1}, // 8

{1, 1, 1, 1, 0, 1, 1} // 9

};

// Display a number on the 7 segment display

void displayNumber(int num) {

const int* segments = SEGMENTS[num];

digitalWrite(A, segments[0]);

digitalWrite(B, segments[1]);

digitalWrite(C, segments[2]);
digitalWrite(D, segments[3]);

digitalWrite(E, segments[4]);

digitalWrite(F, segments[5]);

digitalWrite(G, segments[6]);

void setup() {

// Set 7 segment display pins as output

pinMode(A, OUTPUT);

pinMode(B, OUTPUT);

pinMode(C, OUTPUT);

pinMode(D, OUTPUT);

pinMode(E, OUTPUT);

pinMode(F, OUTPUT);

pinMode(G, OUTPUT);

void loop() {

// Display numbers 0 to 9

for (int i = 0; i < 10; i++) {

displayNumber(i);

delay(1000);

You might also like