Page 322 - 최강 아두이노 퍼스트 참고서
P. 322

http://www.allfirst.co.kr/pds/arduinoLib/7segment_4digit_ex_1.ino
                 #include <SevSeg.h>

                 //Create an instance of the object.
                 // 글로벌 클래스 변수입니다. (전역 클래스 변수)
                 SevSeg myDisplay;

                 //Create global variables
                 unsigned long timer;
                 int deciSecond = 0;

                 void setup()
                 {

                   int displayType = COMMON_CATHODE; //캐소드 모듈 지정.

                   //This pinout is for a regular display
                   int digit1 = 2; //Pin 12 on my 4 digit display
                   int digit2 = 3; //Pin 9 on my 4 digit display
                   int digit3 = 4; //Pin 8 on my 4 digit display
                   int digit4 = 5; //Pin 6 on my 4 digit display

                   //Declare what pins are connected to the segments
                   int segA = 6; //Pin 11 on my 4 digit display
                   int segB = 7; //Pin 7 on my 4 digit display
                   int segC = 8; //Pin 4 on my 4 digit display
                   int segD = 9; //Pin 2 on my 4 digit display
                   int segE = 10; //Pin 1 on my 4 digit display
                   int segF = 11; //Pin 10 on my 4 digit display
                   int segG = 12; //Pin 5 on my 4 digit display
                   int segDP= 13; //Pin 3 on my 4 digit display

                   int numberOfDigits = 4;  //Do you have a 1, 2 or 4 digit
                 display?

                   myDisplay.Begin(displayType, numberOfDigits,
                                   digit1, digit2, digit3, digit4,
                                   segA, segB, segC, segD, segE,
                                   segF, segG, segDP);

                   myDisplay.SetBrightness(100); //Set the display to 100%
                 brightness level

                   timer = millis();
                 }

                 void loop()
                 {
                   //Example ways of displaying a decimal number
                   char tempString[10]; //Used for sprintf






                                                   322
   317   318   319   320   321   322   323   324   325   326   327