/*#include <Adafruit_NeoPixel.h>
#define PIN 6 // Pino conectado ao LED
#define NUM_LEDS 3 // Apenas 3 LED
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show(); // Inicia com o LED apagado
}
void loop() {
// Acende o LED de vermelho
strip.setPixelColor(0, strip.Color(255, 0, 0)); // (R, G, B)
strip.show();
delay(500);
strip.setPixelColor(1, strip.Color(0, 0, 255)); // (R, G, B)
strip.show();
delay(500);
strip.setPixelColor(2, strip.Color(0, 255, 0)); // (R, G, B)
strip.show();
delay(500);
strip.setPixelColor(0, strip.Color(0, 0, 0));
strip.setPixelColor(1, strip.Color(0, 0, 0));
strip.setPixelColor(2, strip.Color(0, 0, 0));
strip.show();
delay(500);
}*/
/*#include <Adafruit_NeoPixel.h>
#define PIN 6 // Pino do LED endereçável
#define NUM_LEDS 1 // Apenas 1 LED
#define POT A0 // Potenciômetro no pino analógico A0
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show();
Serial.begin(9600); // Para visualizar o valor do potenciômetro
}
void loop() {
int leitura = analogRead(POT); // Valor entre 0 e 1023
Serial.println(leitura);
// Divide o potenciômetro em 3 faixas
if (leitura < 341) {
// Faixa 1 → LED vermelho
strip.setPixelColor(0, strip.Color(255, 0, 0));
}
else if (leitura < 682) {
// Faixa 2 → LED verde
strip.setPixelColor(0, strip.Color(0, 255, 0));
}
else {
// Faixa 3 → LED azul
strip.setPixelColor(0, strip.Color(0, 100, 255));
}
strip.show();
delay(50); // Pequena pausa
}*/
#include <Adafruit_NeoPixel.h>
#define PIN 6 // Pino do Arduino ligado ao DIN da fita/módulo
#define NUM_LEDS 3 // Temos 3 LEDs
#define POT A0 // Potenciômetro no pino A0
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show();
Serial.begin(9600); // Para acompanhar no Monitor Serial
}
void loop() {
int leitura = analogRead(POT); // 0–1023
Serial.println(leitura);
// Apaga todos antes de atualizar
strip.clear();
// LED0 → verde se leitura > 20
if (leitura > 20) {
strip.setPixelColor(0, strip.Color(0, 255, 0));
}
// LED1 → azul se leitura > 100
if (leitura > 100) {
strip.setPixelColor(1, strip.Color(0, 0, 255));
}
// LED2 → azul se leitura > 300
if (leitura > 300) {
strip.setPixelColor(2, strip.Color(0, 0, 255));
}
// LED2 → vermelho se leitura > 300 (sobrescreve o azul)
if (leitura > 500) {
strip.setPixelColor(2, strip.Color(255, 0, 0));
}
if (leitura > 600) {
strip.setPixelColor(2, strip.Color(255, 220, 0));
}
strip.show();
delay(50);
}