2015년 강좌 | WS2812B [1개]- 테스트 - AVRstudio
페이지 정보
작성자 키트 작성일17-08-23 16:48 조회3,438회 댓글0건본문
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#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,438
등록된 댓글이 없습니다.