Page 537 - 완) I MDP 프로젝트 작품 보고서(전체과 1학년)1.6
P. 537

나) Source Program
            나-1) ATmega128



            #include <mega128.h>

            #include <delay.h>


            int flag=0;

            int flag_ir=1;
            int speed=210,enable=0xff, motor, time=0;



            void main(void)
            {

                    DDRA=0xff;       //DDR선언
                    DDRC=0xff;

                    DDRE=0x00;
                    DDRF=0xff;



                    TIMSK=0x03;      //타이머카운터 관련 설정
                    TCCR0=0x07;

                    TCNT0=0;


                    UCSR0A=0x00;          //통신 관련 설정

                    UCSR0B=0b11011000;
                    UCSR0C=0b00000110;

                    UBRR0H=0;             //통신 속도 설정
                    UBRR0L=103;



                    SREG=0x80;      //전체 인터럽트 enable
                    EICRA=0xc0;     //외부 인터럽트 관련 선언

                    EIMSK=0x08;


                    while(1)

                    {
                            PORTC=enable & motor;





                                                         -  530  -
   532   533   534   535   536   537   538   539   540   541   542