BASIC4MCU | 질문게시판 | 답변 : AVR LED 교차점등
페이지 정보
작성자 master 작성일2018-09-20 13:46 조회7,857회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=3151
본문
// MCU BASIC: https://www.basic4mcu.com// DateTime : 2018-09-20 오후 1:46:10// by Ok-Hyun Park//#include <avr/io.h>//void delay_sec(int sec){volatile int i,j,k;for(i=0;i<sec;i++){for(j=0;j<500;j++){ for(k=0;k<500;k++); }}}//int main(){unsigned int count1=16,count2=8;float a=2,b=0.5;DDRA=0xff;while(1){PORTA=count1+count2; delay_sec(1);count1=count1*a;count2=count2*b;if(count1==128){ a=0.5; b=2; }if(count1== 16){ a=2; b=0.5; }}}
count1=count1*a;
a가 0.5인 경우에는
count1=count1>>1; 우 쉬프트와 같고
a가 2인 경우에는
count1=count1<<1; 좌 쉬프트와 같습니다.
좌시프트와 우쉬프트를 더해서 출력하는 것은두 개의 LED가 좌우 반대로 쉬프트하면서 출력되는 것입니다.게시판의 글도 참고하세요
댓글 0
조회수 7,857등록된 댓글이 없습니다.