Hello guys, I'm new with Arduino software and electronic world, so feel free to correct me any expression or error.
I started a project where I have to use Arduino to program some led strip with a fade effect. So I buy a "Adafruit pro trinket 5V 16MHz board" and "5V RGB LED strip".
I was looking for a "fade" code to my 5V LED strip but all tutorial I found was to 12V LED strip...
I want a code wich allow me to modify the following parameters:
-The duration of the fade effect.
-The initial and final brightness of the LED strip.
-Alternate colours in the effect.
Finally I found a code, but I wasn't complete so I modify a little and it works.
Now the problem is that I don't know how to edit this code to send different instruction to 2 PINS (for example 4 and 8 ).
I would like that the LED strip, who is connected to the PIN number 4, fade alternating in blue and yellow. On the other hand, the LED strip connected to PIN number 8 I want that only fade in blue...
Here is the code:
#include "FastLED.h"
#define NUM_LEDS 60
CRGB leds[NUM_LEDS];
#define PIN 4
#define PIN2 8
void setup()
{
FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}
void loop() {
FadeInOut(0x00, 0xbf, 0xff);
delay(10);
FadeInOut(0x41, 0xf5, 0x05);
}
void FadeInOut(byte red, byte green, byte blue){
float r, g, b;
for(int k = 50; k < 255; k=k+1) {
r = (k/256.0)*red;
g = (k/256.0)*green;
b = (k/256.0)*blue;
setAll(r,g,b);
delay(15);
}
for(int k = 255; k >= 50; k=k-2) {
r = (k/256.0)*red;
g = (k/256.0)*green;
b = (k/256.0)*blue;
setAll(r,g,b);
delay(15);
}
}
void showStrip() {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
FastLED.show();
#endif
}
void setPixel(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.setPixelColor(Pixel, strip.Color(red, green, blue));
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
#endif
}
void setAll(byte red, byte green, byte blue) {
for(int i = 0; i < NUM_LEDS; i++ ) {
setPixel(i, red, green, blue);
}
showStrip();
}
If you know other simple code post it please!
Thank you so much for your patience!