본문 바로가기

카테고리 없음

마이크로프로세서_7-seg 숫자출력

반응형
/*

* 7seg_first.c

*

* Created: 2021-09-14 오전 10:52:54

* Author : esl

*/



#include <avr/io.h>

#include <util/delay.h>



unsigned char font[10] = {

   0xc0,0xf9,0xa4,

   0xb0,0x99,0x92,

   0x82,0xf8,0x80,0x90

};



int main(void)

{



DDRB = 0xff;

DDRC = 0xff;



PORTB = 0xff;



   while(1){

      for(int i= 1; i < 10; i++){

         for(int j = 1; j < 10; j++){

            for(int t = 0; t < 400; t ++){

               int ten = i * j / 10;

               int one = (i * j) % 10;

               PORTB ^= 1;

               PORTC = ~font[i];

              

               _delay_ms(1);

               PORTC = 0;

               PORTB ^= 1;

               PORTB ^= 1<<1;

      

      

               PORTC = ~font[j];

              

               _delay_ms(1);

               PORTC = 0;

               PORTB ^= 1<<1;

              

               PORTB ^= 1<<2;

               PORTB = 0b00001011;

        

               PORTC = ~font[ten];

            

               _delay_ms(1);

               PORTC = 0;

               PORTB ^= 1<<2;

              

               PORTB ^= 1<<3;

            

               _delay_ms(1);

               PORTC = ~font[one];

            

               _delay_ms(1);

               PORTC = 0;

               PORTB ^= 1<<3;

               _delay_ms(1);

            }

            

            

         }

      }

   }

  





return 0;



}
반응형