Arduino Tutorial

By LiterallyTheOne

2: 7-segment

Arduino Tutorial, 7-segment

Introduction

  • Previous tutorial: GPIO
  • This tutorial: 7-segment
By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, 7-segment

What is a 7-segment?

  • Set of 7 leds + dp
  • Show numbers and letters
  • a to g + dp
By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, 7-segment

Connect a 7-segment to fixed voltage

numbers 7-segment

By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, 7-segment

Create a number

numbers 7-segment

By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, 7-segment

Store the number

dp g f e d c b a
0 0 1 1 1 1 1 1
By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, 7-segment

Connect 7-segment to an Arduino

numbers 7-segment

By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, 7-segment

Store our numbers in our code

char digits[10] = {
    0b00111111, // 0
    ...
};
By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, 7-segment

Show digit function

void show_digit(int digit)
{
  for (int i = 0; i < 8; i++)
  {
    digitalWrite(i, (digits[digit] >> i) & 0b0000'0001);
  }
}
By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, 7-segment

Counter

By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, 7-segment

Counter with pause

By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, 7-segment

Counter with pause and reverse

By Ramin Zarebidoky (LiterallyTheOne)
Arduino Tutorial, 7-segment

By Ramin Zarebidoky (LiterallyTheOne)