Interfacing 7-segment display to Arduino Uno

Interfacing 7-segment display to Arduino Uno

Visit our Instagram page for more embedded information: 

https://www.instagram.com/youtube_way2know/


unsigned char num = 0;

void setup() {

  // put your setup code here, to run once:

  pinMode(2,OUTPUT);

  pinMode(3,OUTPUT);

  pinMode(4,OUTPUT);

  pinMode(5,OUTPUT);

  pinMode(8,OUTPUT);

  pinMode(9,OUTPUT);

  pinMode(10,OUTPUT);

  pinMode(11,OUTPUT);

}

void loop() {

  // put your main code here, to run repeatedly:

  digitalWrite(2,HIGH);

  digitalWrite(3,HIGH);

  digitalWrite(4,HIGH);

  digitalWrite(5,HIGH);

  digitalWrite(8,HIGH);

  digitalWrite(9,HIGH);

  digitalWrite(10,HIGH);

  digitalWrite(11,HIGH);

  delay(500);

  switch(num)

  {

    case 0:

      digitalWrite(2,LOW);

      digitalWrite(3,LOW);

      digitalWrite(4,LOW);

      digitalWrite(5,HIGH);

      digitalWrite(8,LOW);

      digitalWrite(9,LOW);

      digitalWrite(10,LOW);

      digitalWrite(11,HIGH);

      delay(500);

      num++;

    break;

    case 1:

      digitalWrite(2,LOW);

      digitalWrite(3,HIGH);

      digitalWrite(4,HIGH);

      digitalWrite(5,HIGH);

      digitalWrite(8,HIGH);

      digitalWrite(9,HIGH);

      digitalWrite(10,LOW);

      digitalWrite(11,HIGH);

      delay(500);

      num++;

    break;

    case 2:

      digitalWrite(2,LOW);

      digitalWrite(3,LOW);

      digitalWrite(8,LOW);

      digitalWrite(9,LOW);

      digitalWrite(11,LOW);

      delay(500);

      num++;

    break;

    case 3:

      digitalWrite(3,LOW);

      digitalWrite(4,LOW);

      digitalWrite(8,LOW);

      digitalWrite(9,LOW);

      digitalWrite(11,LOW);

      delay(500);

      num++;

    break;

    case 4:

      digitalWrite(4,LOW);

      digitalWrite(8,LOW);

      digitalWrite(10,LOW);

      digitalWrite(11,LOW);

      delay(500);

      num++;

    break;

    case 5:

      digitalWrite(3,LOW);

      digitalWrite(4,LOW);

      digitalWrite(9,LOW);

      digitalWrite(10,LOW);

      digitalWrite(11,LOW);

      delay(500);

      num++;

    break;

    case 6:

      digitalWrite(2,LOW);

      digitalWrite(3,LOW);

      digitalWrite(4,LOW);

      digitalWrite(9,LOW);

      digitalWrite(10,LOW);

      digitalWrite(11,LOW);

      delay(500);

      num++;

    break;

    case 7:

      digitalWrite(4,LOW);

      digitalWrite(8,LOW);

      digitalWrite(9,LOW);

      delay(500);

      num++;

    break;

    case 8:

      digitalWrite(2,LOW);

      digitalWrite(3,LOW);

      digitalWrite(4,LOW);

      digitalWrite(8,LOW);

      digitalWrite(9,LOW);

      digitalWrite(10,LOW);

      digitalWrite(11,LOW);

      delay(500);

      num++;

    break;

    case 9:

      digitalWrite(3,LOW);

      digitalWrite(4,LOW);

      digitalWrite(8,LOW);

      digitalWrite(9,LOW);

      digitalWrite(10,LOW);

      digitalWrite(11,LOW);

      delay(500);

      num = 0;

    break;

  }

}

Post a Comment

0 Comments