BASIC4MCU | AVR 따라하기 | 2015년 강좌 | WS2812B [1개]- 테스트 - AVRstudio
페이지 정보
작성자 키트 작성일2017-08-23 16:48 조회3,339회 댓글0건본문
123456789101112131415161718192021222324252627282930313233343536 #define F_CPU 16000000UL // 16 MHz#include <avr/io.h>#include <util/delay.h>//#define nop2 {asm volatile(" NOP "); asm volatile(" NOP ");}#define nop8 {nop2; nop2; nop2; nop2;}//#define ws2812b_1 PORTB|=4 //PORTB.2#define ws2812b_0 PORTB&=~4 //PORTB.2//void byte_out(unsigned char d){unsigned char i;for(i=0;i<8;i++){if(d&0x80){ ws2812b_1; nop8; ws2812b_0; }else { ws2812b_1; nop2; ws2812b_0; }d<<=1;}}//int main(void){int a,b,c;unsigned char r,g,b;DDRB=4;//while(1){for(a=0;a<256;a++){for(b=0;b<256;b++){for(c=0;c<256;c++){g=(unsigned char)b; r=(unsigned char)a; b=(unsigned char)c;byte_out(g); byte_out(r); byte_out(b);_delay_ms(10);}}}}}cs 돌려보지 않은 것이니 테스트 해 본분이 계시면 동작여부를 댓글로 적어주세요^^
댓글 0
조회수 3,339등록된 댓글이 없습니다.