Hola
Necesito encender y apagar una tira de led Neopixel stick 8 (Adafruit) con una fotocelda y no lo logro, estoy utilizando:
Resistencia variable LDR = 1K Ohm
Resistencia fija= 10k Ohm
Arduino Uno
NeoPixel Stick - 8 LEDs RGB
Este es el código:
const int ledPin = 6;
const int ldrPin = A0;
int delayval = 500;
void setup() {
#if defined (AVR_ATtiny85)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
pixels.begin();
Serial.begin(9600);
pinMode(ledPin,OUTPUT);
pinMode (ldrPin, INPUT);
}
void loop() {
int ldrStatus = analogRead(ldrPin);
if (ldrStatus <=800){
digitalWrite(PIN,LOW);
Serial.println ("LDR is DARK");
}
else {
digitalWrite(PIN,HIGH);
}
for(int i=0;i<NUMPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(50,98,255)); // Moderately bright green color.
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
}