项目作者: xdvrx1

项目描述 :
a simple project in Arduino that uses the breadboard, the microcontroller, the 7-Segment Display and basic programming
高级语言:
项目地址: git://github.com/xdvrx1/single-display-arduino-project.git
创建时间: 2021-01-23T05:31:07Z
项目社区:https://github.com/xdvrx1/single-display-arduino-project

开源协议:MIT License

下载


Display (Output) Arduino Project

updated 21 April 2022

sample project

This is a simple project in Arduino that uses
the breadboard, the Arduino UNO Board,
the 7-Segment Display and basic programming.
Take note, there are several ways to do this
same project but we’ll focus on one.

The Arduino UNO Board

board

The Arduino UNO Board is the basic board
for beginners doing projects in Arduino.

As from the previous project, without
a microcontroller, your only control is
through an external switch. And you
are just limited to that.

The microcontroller will enable you to
program electronic components so that you
can build digital devices that you want
to build.

The Digital Pins

pins

The digital pins are the very first to be
encountered because they can be used by
components in several ways. They will be
connected to the terminals of electronic
components. There are 14 Digital Pins
in Arduino UNO Board.

The GND

gnd

The GND is the floating ground to complete
the circuit. Remember, in an electrical setup
the earth ground is used extensively. In
electronics, it’s the convenience to use
a floating ground.

The BreadBoard

breadboard

The breadboard is your convenience for you to
simply put things in place. Plus,
it provides connections either horizontally
or vertically for further ease. Because
of this, you avoid overlapping wires:
the metal strip at the bottom provides the
connection.

The 7-Segment Display

display

To not complicate things, we just use one 7-Segment
Display for the output. Remember, computer monitors’
concept of display is the same: the dot-and-no-dot
pattern to create a display, whether an image
or letter or numbers. You can do the same thing
by using LEDs to serve as pixels.

But here in our project, we want to use the 7-Segment
Display as an upgrade from the basic LEDs. It’s called
7-Segment Display because there are seven segments of
LEDs, forming the number 8 unlighted.

display2

The 7-Segment Display will either use cathode or
anode. Make sure you got it right. It depends on
your circuit design.

The Arduino Code

There are just two default functions in Arduino:
void setup and void loop.

void setup is where you tell the Arduino board about
the common setup just like whether a digital pin will
be used as output or input.

void loop is where the Arduino board executes
all the commands you put there just like
digitalWrite whether high or low. HIGH means
there is a voltage supplied just like turning
it on through an external switch and LOW means
there is no voltage supplied or there is but is
too low. Voltage that is not
sufficient will still be just like no voltage at all.

Project Guide

Using the TinkerCAD,
here are the steps to create the project:

  1. Make sure that you change the
    7-Segment Display common terminal to
    cathode. setup

  2. Follow the proper wiring:

    |Arduino Pin|Segment Pin|
    |:—-:|:—-:|
    |13|G|
    |12|F|
    |11|A|
    |10|B|
    |9|E|
    |8|D|
    |7|C|
    |6|DP|

  3. Close the circuit by the GND. Use a resistor
    that is exactly 200 ohms (left resistor
    when facing the screen) and 100 ohms for
    the other one.
    left:
    left
    right:
    right

  4. Copy paste the program below:
    ```
    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;

  1. void setup(void)
  2. {
  3. pinMode(A, OUTPUT);
  4. pinMode(B, OUTPUT);
  5. pinMode(C, OUTPUT);
  6. pinMode(D, OUTPUT);
  7. pinMode(E, OUTPUT);
  8. pinMode(F, OUTPUT);
  9. pinMode(G, OUTPUT);
  10. pinMode(H, OUTPUT);
  11. }
  12. //functions to display
  13. //the numbers
  14. void displayZero(void) {
  15. digitalWrite(A, LOW);
  16. digitalWrite(B, HIGH);
  17. digitalWrite(C, HIGH);
  18. digitalWrite(D, HIGH);
  19. digitalWrite(E, HIGH);
  20. digitalWrite(F, HIGH);
  21. digitalWrite(G, HIGH);
  22. digitalWrite(H, LOW);
  23. }
  24. void displayOne(void) {
  25. digitalWrite(A, LOW);
  26. digitalWrite(B, LOW);
  27. digitalWrite(C, LOW);
  28. digitalWrite(D, HIGH);
  29. digitalWrite(E, LOW);
  30. digitalWrite(F, LOW);
  31. digitalWrite(G, HIGH);
  32. digitalWrite(H, LOW);
  33. }
  34. void displayTwo(void) {
  35. digitalWrite(A, HIGH);
  36. digitalWrite(B, LOW);
  37. digitalWrite(C, HIGH);
  38. digitalWrite(D, HIGH);
  39. digitalWrite(E, HIGH);
  40. digitalWrite(F, HIGH);
  41. digitalWrite(G, LOW);
  42. digitalWrite(H, LOW);
  43. }
  44. void displayThree(void) {
  45. digitalWrite(A, HIGH);
  46. digitalWrite(B, LOW);
  47. digitalWrite(C, HIGH);
  48. digitalWrite(D, HIGH);
  49. digitalWrite(E, LOW);
  50. digitalWrite(F, HIGH);
  51. digitalWrite(G, HIGH);
  52. digitalWrite(H, LOW);
  53. }
  54. void displayFour(void) {
  55. digitalWrite(A, HIGH);
  56. digitalWrite(B, HIGH);
  57. digitalWrite(C, LOW);
  58. digitalWrite(D, HIGH);
  59. digitalWrite(E, LOW);
  60. digitalWrite(F, LOW);
  61. digitalWrite(G, HIGH);
  62. digitalWrite(H, LOW);
  63. }
  64. void displayFive(void) {
  65. digitalWrite(A, HIGH);
  66. digitalWrite(B, HIGH);
  67. digitalWrite(C, HIGH);
  68. digitalWrite(D, LOW);
  69. digitalWrite(E, LOW);
  70. digitalWrite(F, HIGH);
  71. digitalWrite(G, HIGH);
  72. digitalWrite(H, LOW);
  73. }
  74. void displaySix(void) {
  75. digitalWrite(A, HIGH);
  76. digitalWrite(B, HIGH);
  77. digitalWrite(C, HIGH);
  78. digitalWrite(D, LOW);
  79. digitalWrite(E, HIGH);
  80. digitalWrite(F, HIGH);
  81. digitalWrite(G, HIGH);
  82. digitalWrite(H, LOW);
  83. }
  84. void displaySeven(void) {
  85. digitalWrite(A, LOW);
  86. digitalWrite(B, LOW);
  87. digitalWrite(C, HIGH);
  88. digitalWrite(D, HIGH);
  89. digitalWrite(E, LOW);
  90. digitalWrite(F, LOW);
  91. digitalWrite(G, HIGH);
  92. digitalWrite(H, LOW);
  93. }
  94. void displayEight(void) {
  95. digitalWrite(A, HIGH);
  96. digitalWrite(B, HIGH);
  97. digitalWrite(C, HIGH);
  98. digitalWrite(D, HIGH);
  99. digitalWrite(E, HIGH);
  100. digitalWrite(F, HIGH);
  101. digitalWrite(G, HIGH);
  102. digitalWrite(H, LOW);
  103. }
  104. void displayNine(void) {
  105. digitalWrite(A, HIGH);
  106. digitalWrite(B, HIGH);
  107. digitalWrite(C, HIGH);
  108. digitalWrite(D, HIGH);
  109. digitalWrite(E, LOW);
  110. digitalWrite(F, HIGH);
  111. digitalWrite(G, HIGH);
  112. digitalWrite(H, LOW);
  113. }
  114. //execute the codes
  115. //by invoking the functions
  116. void loop(void)
  117. {
  118. displayNine();
  119. delay(1000);
  120. displayEight();
  121. delay(1000);
  122. displaySeven();
  123. delay(1000);
  124. displaySix();
  125. delay(1000);
  126. displayFive();
  127. delay(1000);
  128. displayFour();
  129. delay(1000);
  130. displayThree();
  131. delay(1000);
  132. displayTwo();
  133. delay(1000);
  134. displayOne();
  135. delay(1000);
  136. displayZero();
  137. delay(1000);
  138. }
  139. ```
  140. The code will simply have the countdown
  141. but the individual function for a certain
  142. number can be used several times for your
  143. own version. Simply invoke the function
  144. inside the `void loop`.
  1. Of course, simulate the program!

  2. Final Version: add a border using LEDs
    with your own pattern of blinking or
    group of LEDs of your own style.
    Make the 7-Segment Display component
    display letters to form words that have
    significance to you. There should be
    at least 2 words presented and another
    two groups of numbers like your birth date,
    year you were born, significant date
    in your life, lucky numbers for you, etc.
    Explain the significance by using comments.

Finally, the actual project is here:

https://www.tinkercad.com/things/fZCbIFVaMor