psieg / Lightpack

Lightpack and Prismatik open repository
GNU General Public License v3.0
1.59k stars 190 forks source link

How to use with 12V 5050 light strips that have a R G and B on the strip #616

Closed Le0nyx closed 3 months ago

Le0nyx commented 4 months ago

Hello,

I would like to build my own Ambient lights out of the 5050 LED Strips. I have made the circuit necessary, but was wondering if i needed to change something within Prismatik to give the arduino the rgb values instead of what i think it does the custom adressable LED values. How would i do that? Would appreciate some help a lot. I have the circuitry all set up only need the software for it and maybe the code on the arduino.

Screenshot 2024-07-19 193332

zomfg commented 3 months ago

hi prismatik does not require special configuration but your board has to speak one of the protocols supported by prismatik and in prismatik you set that, and 1 (one) LED, since your strip is not addressable (as per the schematic you are showing)

Le0nyx commented 3 months ago

Hello there,

I actually found the solution for my problem. There is nothing wrong with Prismatik. Some settings do need to be adjusted for it to work correctly, although I found out what good middle point i need to use for it. The Arduino just needs some easing to get rid of the flickering. Though be aware with me having some values under zero in my code the lights reach mathematically never zero, but it turned out I kind of like it still being a bit bright even when turning it off in Prismatik.

Though that issue can be handled by a simple if statement set to if it recieves for all 3 values zero or near zero

Here my notes for settings i took:

MOSFETS NEEDED FOR THIS PROJECT RESISTORS AND CABLES NEEDED AND AN ARDUINO

I used Prismatik for this: https://github.com/psieg/Lightpack For what to grab deactivate all other zones and just drag the 1 over the full screen 4 amps max and 50 mili amps per led

screen grabbing average color on all leds 130 ms of frames overbrighten on 36 scene luminosity threshold 12 minimum luminosity level gamma 2.00 overall brightness 100 brightness cap 100

if static light change to mood light and then static and choose colour

The code i have on the arduino actually:

define RED_PIN 9

define GREEN_PIN 10

define BLUE_PIN 11

float currentRed = 0; float currentGreen = 0; float currentBlue = 0;

int targetRed = 0; int targetGreen = 0; int targetBlue = 0;

const int updatesPerSecond = 60; // Adjust this value for the desired updates per second const int delayTime = 1000 / updatesPerSecond; // Delay between updates

void setup() { Serial.begin(115200); pinMode(RED_PIN, OUTPUT); pinMode(GREEN_PIN, OUTPUT); pinMode(BLUE_PIN, OUTPUT); Serial.println("Arduino ready"); }

void loop() { if (Serial.available() >= 3) { targetRed = Serial.read(); targetGreen = Serial.read(); targetBlue = Serial.read(); }

smoothTransition(); delay(delayTime); // Adjust delay for desired updates per second }

void smoothTransition() { float easing = 0.045; // Adjust this value for different easing effects (0 < easing <= 1) float threshold = 1.1; // Only update if the change is larger than this threshold

float deltaRed = targetRed - currentRed; float deltaGreen = targetGreen - currentGreen; float deltaBlue = targetBlue - currentBlue;

if (abs(deltaRed) > threshold) { currentRed += deltaRed * easing; }

if (abs(deltaGreen) > threshold) { currentGreen += deltaGreen * easing; }

if (abs(deltaBlue) > threshold) { currentBlue += deltaBlue * easing; }

analogWrite(RED_PIN, (int)currentRed); analogWrite(GREEN_PIN, (int)currentGreen); analogWrite(BLUE_PIN, (int)currentBlue); }