Lab_interaccio/2022/ines/ines.ino

40 lines
2 KiB
Arduino
Raw Permalink Normal View History

2025-02-25 21:29:42 +01:00
#include <Adafruit_NeoPixel.h>
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1:
#define LED_PIN 22
// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 45
Adafruit_NeoPixel strip(2*LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
uint8_t red[LED_COUNT] = { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,255, 255, 255, 255, 255};
uint8_t green[LED_COUNT] = { 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,255, 255, 255, 255, 255};
uint8_t blue[LED_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,255, 255, 255, 255, 255};
void setup() {
strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255
for(int i=0; i<LED_COUNT; i++) strip.setPixelColor(0, strip.Color(0, 0, 0));
strip.show();
}
void loop() {
for(int i=0; i<LED_COUNT; i++) //Ciclo de encendido
{
strip.setPixelColor(i, strip.Color(red[i], green[i], blue[i]));
strip.setPixelColor(2*LED_COUNT-1-i, strip.Color(red[i], green[i], blue[i]));
strip.show();
delay(1000);
}
delay(1000); //Tiempo de espera entre ciclo y ciclo "Tiempo ENCENDIDO"
for(int i=LED_COUNT; i>=0; i--)//Ciclo de apagado
{
strip.setPixelColor(i, strip.Color(0, 0, 0));
strip.setPixelColor(2*LED_COUNT-1-i, strip.Color(0, 0, 0));
strip.show();
delay(1000);
}
delay(1000); //Tiempo de espera entre ciclo y ciclo "Tiempo APAGADO"
}