Lab_interaccio/2018/LLAC-RGBW-varios/LEDEeffects_Sources/NeoPixel Examples/Cylon/Cylon.ino

116 lines
2.3 KiB
Arduino
Raw Normal View History

2025-02-25 21:29:42 +01:00
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
#include "Adafruit_NeoPixel.h"
#define RADIOSEND false
#define CE_PIN 12
#define CSN_PIN 2
#define DEBUG 0
#define TEST 0
#define RED 11
#define GREEN 10
#define BLUE 9
#define WHITE 6
#define SDO1 8
#define SDO2 4
#define SDO3 3
#define NUMPIXELS1 300 // fuego
#define NUMPIXELS2 150
#define NUMPIXELS3 150
Adafruit_NeoPixel pixels1 = Adafruit_NeoPixel(NUMPIXELS1, SDO1, NEO_GRBW + NEO_KHZ800);
Adafruit_NeoPixel pixels2 = Adafruit_NeoPixel(NUMPIXELS2, SDO2, NEO_GRBW + NEO_KHZ800);
Adafruit_NeoPixel pixels3 = Adafruit_NeoPixel(NUMPIXELS3, SDO3, NEO_GRBW + NEO_KHZ800);
void setup() {
pixels1.begin();
pixels2.begin();
pixels3.begin();
pixels1.show(); // Initialize all pixels to 'off'
pixels2.show(); // Initialize all pixels to 'off'
pixels3.show(); // Initialize all pixels to 'off'
Serial.begin(512000);
}
// *** REPLACE FROM HERE ***
void loop() {
countFrame++;
r = (countFrame / 625.) * 255 ; //rojo
//Serial.println(r);
Serial.println(countFrame*16);
//g = neopix_gamma[(int)(255.*countFrame / totalFrames)] * green / 255;
//b = neopix_gamma[(int)(255.*countFrame / totalFrames)] * blue / 255;
//w = neopix_gamma[(int)(255.*countFrame / totalFrames)] * white / 255;
if(countFrame > 625)
countFrame=0;
//colorFill(CRGB::Red);
//colorFill(CRGB::Green);
//colorFill(CRGB::Blue);
//fillWhite();
//rainbowLoop();
setAll(r, 0, 0, 0);
splitStrip();
showStrip();
//FastLED.delay(1000/FRAMES_PER_SECOND);
}
void splitStrip()
{
// CONVERSION DE UNA ANIMACION DE 5M A DOS TRAMOS
for ( int i = 0; i < 150 ; i++) // numPixels/2
{
pixels2.setPixelColor( i, pixels1.getPixelColor(i) );
pixels3.setPixelColor( i, pixels1.getPixelColor(i + 150) );
}
}
void showStrip()
{
//pixels1.show(); // tira entera de 5m
pixels2.show(); // parte 1 de 2.5m
pixels3.show(); // parte 2 de 2.5m
}
void setPixel(int Pixel, byte red, byte green, byte blue, byte white)
{
pixels1.setPixelColor(Pixel, pixels1.Color(red, green, blue, white));
}
void setAll(byte red, byte green, byte blue, byte white)
{
for (int i = 0; i < NUMPIXELS1; i++ ) {
setPixel(i, red, green, blue, white);
}
}