Hallo zusammen
Ich will mich gerade darin versuchen die Helligkeit meiner LED Strips über ein Potentiometer zu regeln während die anderen Effekte ungehindert weiterlaufen, zudem weiß ich leider noch nicht wie der Arduino mit den Porti verbunden wird und der Sketch dafür aussieht.
Ich habe allerdings im Internet viel Recherchiert und alle beilspiele die da gezeigt wurden waren immer nur mit einer LED und keinen LED Strips, zudem finde ich die mit Handy aufgenommenen YouTube Tutorials ziemlich schlecht.
Einige der Tutorials waren entweder mit neoPixel oder zu LED Strips die ich nicht besitze, leider weiß ich nicht ob fastLED und neoPixel zusammen funktioniert
Da meine Frage wie wird der Porti an den Arduino angebunden und wie integriere ich das im folgenden Sketch:
#include <FastLED.h>
#define NUM_LEDS 68 // How many leds are in the strip?
#define DATA_PIN 6
#define SPARKING 120
#define COOLING 55
#define FRAMES_PER_SECOND 60.
#if FASTLED_VERSION < 3001000
#error "Requires FastLED 3.1 or later; check github for latest code."
#endif
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
#define BRIGHTNESS 255
bool gReverseDirection = false;
CRGB leds[NUM_LEDS]; // This is an array of leds. One item for each led in your strip.
uint8_t gHue = 0; // rotating "base color" used by many of the patterns
const byte tasterPin = 2;
const unsigned long bounceTime = 40;
byte auswahl = 0;
const byte maxFunktion = 7;
void setup()
{
pinMode (tasterPin, INPUT_PULLUP);
FastLED.addLeds<WS2811, DATA_PIN, GRB>(leds, NUM_LEDS);
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS)
.setCorrection(TypicalLEDStrip)
.setDither(BRIGHTNESS < 255);
// set master brightness control
FastLED.setBrightness(BRIGHTNESS);
}
void loop()
{
funktionAuswahl();
}
void funktionAuswahl()
{
static unsigned long pressTimer = 0;
static bool lastPressed = false;
if (!digitalRead(tasterPin))
{
if (!lastPressed)
{
auswahl++;
if (auswahl >= maxFunktion)
{
auswahl = 0;
}
pressTimer = millis();
lastPressed = true;
}
}
else if (millis() - pressTimer > bounceTime)
{
lastPressed = false;
}
switch (auswahl)
{
case 0: rainbow(); break;
case 1: confetti(); break;
case 2: bpm(); break;
case 3: Fire2012(); break;
case 4: juggle(); break;
case 5: sinelon(); break;
case 6: pride(); break;
}
}
void rainbow()
{
fill_rainbow( leds, NUM_LEDS, gHue, 7);
FastLED.show();
EVERY_N_MILLISECONDS( 10 )
{
gHue++;
}
}
void confetti()
{
fadeToBlackBy( leds, NUM_LEDS, 10);
EVERY_N_MILLISECONDS( 150 )
FastLED.show();
int pos = random16(NUM_LEDS);
leds[pos] += CHSV( gHue + random8(64), 200, 255);
}
void bpm()
{
uint8_t BeatsPerMinute = 62;
CRGBPalette16 palette = PartyColors_p;
FastLED.show();
uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
for ( int i = 0; i < NUM_LEDS; i++) //9948
{
leds[i] = ColorFromPalette(palette, gHue + (i * 2), beat - gHue + (i * 10));
}
}
void Fire2012()
{
// Array of temperature readings at each simulation cell
static uint8_t heat[NUM_LEDS];
FastLED.show();
FastLED.delay(100 / FRAMES_PER_SECOND);
// Step 1. Cool down every cell a little
for ( int i = 0; i < NUM_LEDS; i++)
{
heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2));
Serial.print(F("Step1: ")); Serial.println(i);
}
// Step 2. Heat from each cell drifts 'up' and diffuses a little
for ( int k = NUM_LEDS - 1; k >= 2; k--)
{
heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
Serial.print(F("Step2: ")); Serial.println(k);
}
// Step 3. Randomly ignite new 'sparks' of heat near the bottom
if ( random8() < SPARKING )
{
int y = random8(7);
heat[y] = qadd8( heat[y], random8(160, 255) );
Serial.print(F("Step3: ")); Serial.println(y);
}
// Step 4. Map from heat cells to LED colors
for ( int j = 0; j < NUM_LEDS; j++)
{
Serial.print(F("Step4: ")); Serial.println(j);
CRGB color = HeatColor( heat[j]);
int pixelnumber;
if ( gReverseDirection )
{
pixelnumber = (NUM_LEDS - 1) - j;
}
else
{
pixelnumber = j;
}
leds[pixelnumber] = color;
Serial.print(F("Step4 pixel: ")); Serial.println(pixelnumber);
}
}
void juggle() {
// eight colored dots, weaving in and out of sync with each other
fadeToBlackBy( leds, NUM_LEDS, 20);
FastLED.show();
FastLED.delay(50 / FRAMES_PER_SECOND);
uint8_t dothue = 0;
for( int i = 0; i < 8; i++) {
leds[beatsin16( i+7, 0, NUM_LEDS-1 )] |= CHSV(dothue, 200, 255);
dothue += 32;
}
}
void sinelon()
{
// a colored dot sweeping back and forth, with fading trails
fadeToBlackBy( leds, NUM_LEDS, 20);
FastLED.show();
FastLED.delay(50 / FRAMES_PER_SECOND);
int pos = beatsin16( 13, 0, NUM_LEDS-1 );
leds[pos] += CHSV( gHue, 255, 192);
}
void pride()
{
static uint16_t sPseudotime = 0;
static uint16_t sLastMillis = 0;
static uint16_t sHue16 = 0;
FastLED.show();
FastLED.delay(30 / FRAMES_PER_SECOND);
uint8_t sat8 = beatsin88( 87, 220, 250);
uint8_t brightdepth = beatsin88( 341, 96, 224);
uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256));
uint8_t msmultiplier = beatsin88(147, 23, 60);
uint16_t hue16 = sHue16;//gHue * 256;
uint16_t hueinc16 = beatsin88(113, 1, 3000);
uint16_t ms = millis();
uint16_t deltams = ms - sLastMillis ;
sLastMillis = ms;
sPseudotime += deltams * msmultiplier;
sHue16 += deltams * beatsin88( 400, 5,9);
uint16_t brightnesstheta16 = sPseudotime;
for( uint16_t i = 0 ; i < NUM_LEDS; i++) {
hue16 += hueinc16;
uint8_t hue8 = hue16 / 256;
brightnesstheta16 += brightnessthetainc16;
uint16_t b16 = sin16( brightnesstheta16 ) + 32768;
uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
bri8 += (255 - brightdepth);
CRGB newcolor = CHSV( hue8, sat8, bri8);
uint16_t pixelnumber = i;
pixelnumber = (NUM_LEDS-1) - pixelnumber;
nblend( leds[pixelnumber], newcolor, 64);
}
}
Zudem finde ich, dass man hier als Neuling im Arduino Forum die besten Antworten und Hilfestellungen bekommt
Vielen Dank im vorraus