빗물 측정 센서 (MH-RD)로 네오픽셀 연출을 하려고하는데요,
On/Off 랑 아날로그 값으로 효과를 변하게 하려고 합니다
다리있는 led로는 성공했고, 레인센서 값은 잘 출력되는데 네오픽셀을 코딩하는게 어렵네요 ㅠㅠ
네오픽셀도 잘되는 거 확인했습니다 도와주세요 ㅠㅠ
#include <Adafruit_NeoPixel.h>
#define PIN 6
int rainPin = A0;
//네오픽셀을 사용하기 위해 객체 하나를 생성한다.
//첫번째 인자값은 네오픽셀의 LED의 개수
//두번째 인자값은 네오픽셀이 연결된 아두이노의 핀번호
//세번째 인자값은 네오픽셀의 타입에 따라 바뀌는 flag
Adafruit_NeoPixel strip = Adafruit_NeoPixel(9, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin(); //네오픽셀을 초기화하기 위해 모든LED를 off시킨다
strip.show();
pinMode(rainPin, INPUT);
pinMode(PIN6, OUTPUT);
}
void loop() {
int sensorValue = analogRead(rainPin);
Serial.print(sensorValue);
if(sensorValue > 800){
Serial.println(" - It's dry");
//아래의 순서대로 NeoPixel을 반복한다.
colorWipe(strip.Color(0, 0, 0), 50); //빨간색 출력
colorWipe(strip.Color(0, 0, 0), 50); //녹색 출력
colorWipe(strip.Color(0, 0, 0), 50); //파란색 출력
}
else if(sensorValue < 800 && 500 <= sensorValue ) {
Serial.println(" - It's raining");
theaterChase(strip.Color(127, 127, 127), 50); //흰색 출력
theaterChase(strip.Color(127, 0, 0), 50); //빨간색 출력
theaterChase(strip.Color( 0, 0, 127), 50); //파란색 출력
}
else {
Serial.println(" - It's wet");
//화려하게 다양한 색 출력
rainbow(20);
rainbowCycle(20);
theaterChaseRainbow(50);
}
}
여기서 pinMode(PIN6, OUTPUT); 를 쓰는 게 맞나요? 그리고 digitalWrite 대신 colorWipe 쓰는 걸로 알았는데 colorWipe is not declared in this scope라고 뜹니다......
|