第六课:学习如何 使用 七段数码管 (7 segment LED display)


标签:
arduino电子microcontroller机器人初学新手教程学习七段数码管it |
分类: Arduino电子 |
This is what you
will get at the end of the tutorial:
It basically
consists of 7 LEDs, (8 if include decimal point). Just like
controlling a single LED, we need to connect each 'segment LED' to
a Arduino digital pin. Here is the circuit diagram of the LED
display:
http://2.bp.blogspot.com/-ep3MiNosMrg/Tskcc0aWJgI/AAAAAAAAAFs/24_2Ndw5aDM/s320/7segLed.gif使用 七段数码管 (7 segment LED display)" TITLE="第六课:学习如何 使用 七段数码管 (7 segment LED display)" />
You might notice,
there are 2 different type of them, don't be scared by them,
because in the market, the "Common Cathode" type is the most
popular so you won't need to care about the other
type.
Basically, all you
need to do is to connect each LED with a pin, and connect the
shared Gnd connector to the ground pin.
Next you will need
to program it, so required LEDs
are switched on to display different
number.
Here is my
circuit diagram:
http://4.bp.blogspot.com/-cqf1BGQTAdA/Tskcgdh9CiI/AAAAAAAAAF0/2l02hGl9KOk/s1600/%E5%9B%BE%E5%83%8F+23.png使用 七段数码管 (7 segment LED display)" TITLE="第六课:学习如何 使用 七段数码管 (7 segment LED display)" />
Coding:
I have created
a class for using the 7 seg LED display, it's not a complete
working class, but gives a few very useful basic functions. Feel
free to expand it and add new useful functions, or create your own
class.
Seven_Seg_LED_Display.h:
/* */#include "WProgram.h" enum class }; |
Seven_Seg_LED_Display.cpp:
#include "Seven_Seg_LED_Display.h" LEDDisplay::LEDDisplay } LEDDisplay::LEDDisplay(int } void |