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

}


            2)2차  프로그램


            #include  <avr/io.h>
            #include  <util/delay.h>
            #include  <avr/interrupt.h>


            void  system_init()
            {
            DDRB=0xff;
            PORTB=0x00;
            DDRE=0xff;
            DDRD=0x00;
            TCCR1A=0xaa;
            TCCR1B=0x1a;
            TCCR3A=0xaa;
            TCCR3B=0x1a;
            ICR1=19999;
            ICR3=19999;
            EIMSK=0x0f;
            EICRA=0xff;
            SREG|=0x80;
            }


            void   RC_Motor1(int    angle)   //OCR1A=PB5(15Pin),     OCR1B=PB6(16Pin),     OCR3A=PE3(5Pin),
            OCR3B=PE4(6Pin)
            {
            int  i;
            if(angle<-90)  angle=-90;
            if(angle>90)  angle=90;
            i=(angle+90)*20+14000;
            OCR1A=i;
            }


            void   RC_Motor2(int    angle)   //OCR1A=PB5(15Pin),     OCR1B=PB6(16Pin),     OCR3A=PE3(5Pin),
            OCR3B=PE4(6Pin)
            {
            int  i;
            if(angle<-90)  angle=-90;
            if(angle>90)  angle=90;




                                                         -  740  -
   742   743   744   745   746   747   748   749   750   751   752