3 Develop an interfacing circuit and a sketch to display decimal data on 7-Segments. The 3- digit number is sent over serial communication.

 Here i am using online IDE Tinkercad . If you don't know what is tinkercad then refer my blog HERE or else you can use offline IDE also.

Code:-

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;

 

 

void setup(void)

{

  pinMode(A, OUTPUT);

  pinMode(B, OUTPUT);

  pinMode(C, OUTPUT);

  pinMode(D, OUTPUT);

  pinMode(E, OUTPUT);

  pinMode(F, OUTPUT);

  pinMode(G, OUTPUT);

  pinMode(H, OUTPUT);

}

 

//My Functions

 

void zero(void) {

  digitalWrite(A, LOW);

  digitalWrite(B, HIGH);

  digitalWrite(C, HIGH);

  digitalWrite(D, HIGH);

  digitalWrite(E, HIGH);

  digitalWrite(F, HIGH);

  digitalWrite(G, HIGH);

  digitalWrite(H, LOW);

}

 

void one(void) {

  digitalWrite(A, LOW);

  digitalWrite(B, LOW);

  digitalWrite(C, LOW);

  digitalWrite(D, HIGH);

  digitalWrite(E, LOW);

  digitalWrite(F, LOW);

  digitalWrite(G, HIGH);

  digitalWrite(H, LOW);

}

 

void two(void) {

  digitalWrite(A, HIGH);

  digitalWrite(B, LOW);

  digitalWrite(C, HIGH);

  digitalWrite(D, HIGH);

  digitalWrite(E, HIGH);

  digitalWrite(F, HIGH);

  digitalWrite(G, LOW);

  digitalWrite(H, LOW);

}

 

void three(void) {

  digitalWrite(A, HIGH);

  digitalWrite(B, LOW);

  digitalWrite(C, HIGH);

  digitalWrite(D, HIGH);

  digitalWrite(E, LOW);

  digitalWrite(F, HIGH);

  digitalWrite(G, HIGH);

  digitalWrite(H, LOW);

}

 

void four(void) {

  digitalWrite(A, HIGH);

  digitalWrite(B, HIGH);

  digitalWrite(C, LOW);

  digitalWrite(D, HIGH);

  digitalWrite(E, LOW);

  digitalWrite(F, LOW);

  digitalWrite(G, HIGH);

  digitalWrite(H, LOW);

}

 

void five(void) {

  digitalWrite(A, HIGH);

  digitalWrite(B, HIGH);

  digitalWrite(C, HIGH);

  digitalWrite(D, LOW);

  digitalWrite(E, LOW);

  digitalWrite(F, HIGH);

  digitalWrite(G, HIGH);

  digitalWrite(H, LOW);

}

 

void six(void) {

  digitalWrite(A, HIGH);

  digitalWrite(B, HIGH);

  digitalWrite(C, HIGH);

  digitalWrite(D, LOW);

  digitalWrite(E, HIGH);

  digitalWrite(F, HIGH);

  digitalWrite(G, HIGH);

  digitalWrite(H, LOW);

}

 

void seven(void) {

  digitalWrite(A, LOW);

  digitalWrite(B, LOW);

  digitalWrite(C, HIGH);

  digitalWrite(D, HIGH);

  digitalWrite(E, LOW);

  digitalWrite(F, LOW);

  digitalWrite(G, HIGH);

  digitalWrite(H, LOW);

}

 

void eight(void) {

  digitalWrite(A, HIGH);

  digitalWrite(B, HIGH);

  digitalWrite(C, HIGH);

  digitalWrite(D, HIGH);

  digitalWrite(E, HIGH);

  digitalWrite(F, HIGH);

  digitalWrite(G, HIGH);

  digitalWrite(H, LOW);

}

 

void nine(void) {

  digitalWrite(A, HIGH);

  digitalWrite(B, HIGH);

  digitalWrite(C, HIGH);

  digitalWrite(D, HIGH);

  digitalWrite(E, LOW);

  digitalWrite(F, HIGH);

  digitalWrite(G, HIGH);

  digitalWrite(H, LOW);

}

 

// Start

void loop(void)

{

  zero();

  delay(1000);

 

  one();

  delay(1000);

 

  two();

  delay(1000);

 

  three();

  delay(1000);

 

  four();

  delay(1000);

 

  five();

  delay(1000);

 

  six();

  delay(1000);

 

  seven();

  delay(1000);

 

  eight();

  delay(1000);

 

  nine();

  delay(1000);

}

 Output:-



Comments

Popular Posts

What is Tinkercad ? How to use Tinkercad ?

Connect switch to Arduino. If switch is on than print ”ON” else print “OFF” on serial monitor.

Set the time using four switch and display the clock on LCD using arduino ** SW1 : when press, increment 1 digit ** SW2 : when press, decrement 1 digit ** SW3 : when press, display set time and start the clock ** SW4 : when press, reset the clock