1. 프로젝트 사용한 보드 종류
(아두이노 UNO)
2. 사용한 개발 프로그램명
(아두이노 LED스트립)
3. 사용한 센서 모델명
((PP-A293W) 5V WS2812B 네오픽셀 RGB LED바 1M 60개)
4. 연결한 회로 설명
PIN 5번 스트립 1, PIN 6번 스트립 2로 두개의 스트립 설치
5. 소스코드 (주석 필수)
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 5
Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
#define PIN 6
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
#if defined (__AVR_ATtiny85__)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
strip1.begin();
strip1.show(); // Initialize all pixels to 'off'
strip2.begin();
strip2.show(); // Initialize all pixels to 'off'
}
void loop() {
theaterChase(strip2.Color(5, 5, 5), 100); //흰색 흘러감
colorWipe(strip1.Color(0,255,0,0),0); //녹색 켜짐
delay(1000);
colorWipe(strip1.Color(0,0,0,0),0); //녹색 꺼짐
delay(1000);
}
void colorWipe(uint32_t c, uint8_t wait) {
for(uint16_t a=0; a<strip1.numPixels(); a++) {
strip1.setPixelColor(a-1, c);
strip1.show();
delay(wait);
}
}
void theaterChase(uint32_t c, uint8_t wait){
for (int j=0; j<1; j++) {
for (int q=0; q < 15; q++) {
for (int i=0; i < strip2.numPixels(); i=i+15) {
strip2.setPixelColor(i+q, c);
strip2.setPixelColor(i+q+1, c);
strip2.setPixelColor(i+q+2, c);
strip2.setPixelColor(i+q+3, c);
strip2.setPixelColor(i+q+4, c);
}
strip2.show();
delay(wait);
for (int i=0; i < strip2.numPixels(); i=i+15) {
strip2.setPixelColor(i+q, 0);
}
}
}
}
6. 문제점 및 에러 내용
(현재상태에서는 스트립1이후 스트립2가 작동하고 다시 스트립 1이 작동으로 반복합니다.
스트립1과 스트립2를 동시에 움직이게 하고 싶습니다.)
|