Hallo,
leider brauche ich Hilfe, da ich nicht selber drauf komme.
Ich habe div.Steuerungen für mein Salzwasserbecken programmiert, soweit funktioniert auch alles, bis auf die Anzeige im LCD Display für den PWM Wert d.h ich möchte gerne den Wert von dem
byte whiteLeds[96] aufgreifen, durch 255 teilen und mal 100 multiplizieren, so das im Display angezeigt wird bei wieviel % die LED Steuerung ist.Ich komme aber nicht an diesen Wert von 0-255 ran.
Für eure Hilfe wäre ich dankbar
CODE
#include
#include
#include
// Next comes variables for white leds, you have to do the same for blues too.
byte pwmWhite = 0;
// Next idea from Dave_uk, thanks (48" LED fixture - Lots of photos - Lighting Forum - Nano-Reef Community)
// Array of pwm values for 15 minute sections
byte whiteLeds[96] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 00-03
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 00-06
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 06-09
20, 30, 40, 50, 60, 80, 100, 120, 140, 160, 180, 200, // 09-12
220, 240, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 12-15
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, // 15-18
240, 220, 200, 180, 160, 140, 120, 100, 80, 80, 80, 60, // 18-21
60, 40, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0 // 21-24
};
byte whiteMaxCurrent = 70; // Percentage of, 70 is 70%, so 1000mA puckbuck is driven at 700mA
// Next the pin for writing
byte whitePin = 11;
void setup() {
// Setup stuff, LCD, pins, RTC etc.
}
void loop() {
// Main loop
getWhitePwm();
analogWrite(whitePin, pwmWhite);
}
void getWhitePwm() {
int tempIndex = 0; // Index for the array containing dimming values for the leds, calculated in 15 mins sectors
long tempTime = 0; // Used to store number of seconds since last midnight
pwmWhite = 0; // Public variable. Reset the value (just to be sure)
tempTime = elapsedSecsToday(now()); // From Time.h, seconds since last midnight, now() is current time
// Check out what is the index of 15 min sections
tempIndex = (tempTime / (SECS_PER_HOUR / 4)); // macro SECS_PER_HOUR from Time.h
// Calculate the PWM value according the index and maximum power we have defined.
pwmWhite = ( whiteLeds[tempIndex] * (whiteMaxCurrent) /100 );
}