Page 154 - MDP2020-1
P. 154

|    인천전자마이스터고등학교  ·············································································································
            148

                나.  fnd  숫자  출력  프로그램  소스


            int  digit[]  =  {1,  2,  3  ,4};
            int  segment[]  =  {5,  6,  7,8,  9,  10,  11,  12};

            byte  digits_data[10]  =  {0xfc,  0x60,  0xda,  0xf2,  0x66,  0xb6,  0xbe,  0xe4,  0xfe,  0xe6};
            int  blue=0,  red=0,  jum=0,bluebutton=A0,  hab=0,  four=0,  three=0,  two=0,  one=0;
            int  lay  =  0;



            void  setup()  {
                for(int  i=0;i<8;i++){
                    pinMode(segment[i],  OUTPUT);}//  핀들  출력  설정

                for(int  i=0;i<4;i++){
                    pinMode(digit[i],  OUTPUT);}//  세그먼트  핀  출력  설정


                pinMode(bluebutton,  INPUT);
                pinMode(redbutton,INPUT);
            }

            void  math(int  k){
                if(k==2  &&  lay==1){
                    lay=0;
                    red+=1;  //  1자리가  변경  문제
                  }
                if(k==1  &&  lay==1){

                    lay=0;
                    blue+=1;  //  100자리가  변경
                }
                hab=red*100+blue;
                four=(hab/1000)%10;

                three=(hab/100)%10;
                two=(hab/10)%10;
                one=(hab/1)%10;
                for(int  i=0;i<10;i++){
              show_digit(1,two);  //  1번핀에  ONE출력

              delay(5);
              show_digit(2,  one);  //  2번핀에  two출력
              delay(5);
              show_digit(3,  four);  //  3번핀에  three출력
              delay(5);

              show_digit(4,  three);  //  4번핀에  four출력
              delay(5);
   149   150   151   152   153   154   155   156   157   158   159