BASIC4MCU | 질문게시판 | 답변 : AVR studio의 코딩을 codevision에서 실행하고 싶습니다 그리고 AVR studio에서 코드가 빌드가안됩…
페이지 정보
작성자 master 작성일2019-05-18 22:36 조회4,513회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=8663
본문
![]() | WS2812B - RGB 최소 밝기 - AVRstudio2017.08.23, #define F_CPU 16000000UL // 16 MHz #include <avr/io.h> #include <util/delay.h> // #define nop2 {asm volati… WWW.BASIC4MCU.COM |
![]() | WS2812B - RGB 최소 밝기2017.08.23, #include #include // #define nop2 {#asm( nop ); #asm( nop );} #define nop8 {nop2; nop2; nop2; nop2;} … WWW.BASIC4MCU.COM |
// 전자공작 : http://cafe.naver.com/circuitsmanual// DateTime : 2019-05-18 오후 10:42:20// by Ok-Hyun Park//#define F_CPU 16000000UL //내부 CPU 클록 16000000Hz#include <avr/io.h>#include <avr/interrupt.h>#include <stdio.h>#include <util/delay.h>//#include “usart.h”//#define LED_SETTING DDRA|=1<<PA0 //LED 연결 핀을 출력 상태로#define S0 PB0 // 색 감지 센서 주파수%조정#define S1 PB1 // 색 감지 센서 주파수%조정#define S2 PB2 // 색상 조정#define S3 PB3 // 색상 조정#define S4 PB4 // TCS3200 라이트//#define nop2 {asm volatile(" NOP "); asm volatile(" NOP ");} // 어셈블리어 2클록 딜레이#define nop6 {nop2;nop2;nop2;} // 어셈블리어 6클록 딜레이#define nop12 {nop2;nop2;nop2;nop2;nop2;nop2;} // 어셈블리어 12클록 딜레이#define ws2812b_1 PORTA|=(1<<PA0) // LED 켜기#define ws2812b_0 PORTA&=~(1<<PA0) // LED 끄기//volatile enum state_m{NORMAL,ROMANTIC,COLORCHANGE,BLUETOOTH} statem=0; // 모드 선언 열거volatile unsigned int light=50; // 밝기 변수[0~255]volatile unsigned int bright=2; // 밝기 변수[light/25][0~10]volatile unsigned int play=0; // 상태 사용 변수volatile unsigned int number=0; // 타이머 오버 플로 1s 단위를 위한 변수volatile unsigned int value=0; // 주파수 측정 변수volatile unsigned int shift; // ROMANTIC MODE 색깔변경volatile unsigned int t;volatile unsigned int red_fre; // RGB R 주파수volatile unsigned int blue_fre; // RGB B 주파수volatile unsigned int green_fre; // RGB G 주파수volatile enum state_t{ RED,BLUE,GREEN} statet=RED; // 주파수 열거volatile char led[13][3];volatile char receive;//volatile char led_romantic[156][3]={{255,0,0},{ 245,0,10},{ 235,0,20},{ 224,0,31},{ 214,0,41},{ 204,0,51},{ 194,0,61},{ 184,0,71},{ 173,0,82},{ 163,0,92},{153,0,102},{ 143,0,112},{ 133,0,122},{ 122,0,133},{ 112,0,143},{ 102,0,153},{ 92,0,163},{ 82,0,173},{ 71,0,184},{ 61,0,194},{51,0,204},{ 41,0,214},{ 31,0,224},{ 20,0,235},{ 10,0,245},{ 0,0,255},{ 0,0,255},{ 0,10,245},{ 0,20,235},{ 0,31,224},{0,41,214},{ 0,51,204},{ 0,61,194},{ 0,71,184},{ 0,82,173},{ 0,92,163},{ 0,102,153},{ 0,112,143},{ 0,122,133},{ 0,133,122},{0,143,112},{ 0,153,102},{ 0,163,92},{ 0,173,82},{ 0,184,71},{ 0,194,61},{ 0,204,51},{ 0,214,41},{ 0,224,31},{ 0,235,20},{0,245,10},{ 0,255,0},{ 0,255,0},{ 10,245,0},{ 20,235,0},{ 31,224,0},{ 41,214,0},{ 51,204,0},{ 61,194,0},{ 71,184,0},{82,173,0},{ 92,163,0},{ 102,153,0},{ 112,143,0},{ 122,133,0},{ 133,122,0},{ 143,112,0},{ 153,102,0},{ 163,92,0},{ 173,82,0},{184,71,0},{ 194,61,0},{ 204,51,0},{ 214,41,0},{ 224,31,0},{ 235,20,0},{ 245,10,0},{ 255,0,0},//{255,0,0},{ 245,0,10},{ 235,0,20},{ 224,0,31},{ 214,0,41},{ 204,0,51},{ 194,0,61},{ 184,0,71},{ 173,0,82},{ 163,0,92},{153,0,102},{ 143,0,112},{ 133,0,122},{ 122,0,133},{ 112,0,143},{ 102,0,153},{ 92,0,163},{ 82,0,173},{ 71,0,184},{ 61,0,194},{51,0,204},{ 41,0,214},{ 31,0,224},{ 20,0,235},{ 10,0,245},{ 0,0,255},{ 0,0,255},{ 0,10,245},{ 0,20,235},{ 0,31,224},{0,41,214},{ 0,51,204},{ 0,61,194},{ 0,71,184},{ 0,82,173},{ 0,92,163},{ 0,102,153},{ 0,112,143},{ 0,122,133},{ 0,133,122},{0,143,112},{ 0,153,102},{ 0,163,92},{ 0,173,82},{ 0,184,71},{ 0,194,61},{ 0,204,51},{ 0,214,41},{ 0,224,31},{ 0,235,20},{0,245,10},{ 0,255,0},{ 0,255,0},{ 10,245,0},{ 20,235,0},{ 31,224,0},{ 41,214,0},{ 51,204,0},{ 61,194,0},{ 71,184,0},{82,173,0},{ 92,163,0},{ 102,153,0},{ 112,143,0},{ 122,133,0},{ 133,122,0},{ 143,112,0},{ 153,102,0},{ 163,92,0},{ 173,82,0},{184,71,0},{ 194,61,0},{ 204,51,0},{ 214,41,0},{ 224,31,0},{ 235,20,0},{ 245,10,0},{ 255,0,0}}; //로맨틱 모드//void byte_out(int d){char i;for(i=0; i<8; i++){// if(d&0x80){ ws2812b_1; nop12; ws2812b_0; }if(d&0x80){ws2812b_1;nop12;ws2812b_0;}else { ws2812b_1; nop6; ws2812b_0; }d<<=1;}} // LED 색상 제어ISR(INT2_vect){ play=1; PORTB&=~(1<<S4); } // 색상 감지 기능 OFF,색깔 고정(4번 버튼)//ISR(INT3_vect){ // 현재 스탠드의 모드를 바꾸어줌(5번 버튼)for(int x=0; x<9; x++){ byte_out(0); byte_out(0); byte_out(0); }_delay_ms(50);receive=0; bright=2; light=50;if(++statem>1)statem=0;_delay_ms(500); //스위치 채터링 방지용 딜레이}//int main(){while(1){}}
댓글 0
조회수 4,513등록된 댓글이 없습니다.