Hello, I am working on a code for PWM fading LEDS that uses addpoints to call the pwm pin to an intensity 0-255. I have the code uploaded and it runs fine when I use real numbers for the time, but I would like the points to be determined off of a "set_on" time that can be set by pushing buttons. I was able to write code for setting the on time, but can't figure out how to set the off time as a function of the on time. i.e. turn off 16 hours after set_on. When I upload the code, set on works but off shows 2 hours after the initial programmed time of 20 regardless of what I set the on time to via the buttons
How do I use the value of set_on as a reference later in the script? i.e. turn lights on 30 min after set_on
I would also like to reference the value of intensity to display as a % and also trigger different .gifs based on intensity value on an OLED. If I ever get that far, lol.
I had tried searching google and found the variables page on the arduino site and also a link talking about passing a value as a reference or by using foo(). Its all very confusing to me
The code and supporting files are attached as they are too long to post, but here are some snippets of the parts in question
in this section when I upload this test in the code, the light comes on at 20:23 even if I set the on time to 19,21 etc. and the voltage coming out of pin 9 seems really small when its picking a random number like the first instance where I put random(70-100) I should be getting 30-40%
of 5v so 1.5-2v but Im seeing .15v but when I put in an actual number like 230 after it I am seeing 3v is that because Im using a small LED with a resister as opposed to my meanwell and its external power supply? Even then, if 3V is my max 30-40% of that would be .9-1.2V
/////////////////////////Schedule////////////////////////////
//* /Test: comment this out and uncomment //Run: to run full schedule
int channelNo = 0;
int pin = 9;
Channels[0] = Channel(pin, MaxPoints, fademode_exponential, Points[channelNo]); // Initialize channel and choose FadeMode
//--Channel-#-/Add event(----Hours---,----Minutes----,----Intensity----);--//--------Description----------------------------//
Channels[0].AddPoint ( (set_on) , 20 , 0 ); // start of day (dawn) light should be off
Channels[0].AddPoint ( (set_on) , 23 , random(70-100) ); // fades light up to 33-40% in the first 3 minutes
Channels[0].AddPoint ( (set_on) , 26 , 230 ); // fades light up to 90% over the next 3 min
Channels[0].AddPoint ( (set_on) , 28 , random(30-60) ); // fades light down to 15-25% @ 8 min elapsed time
Channels[0].AddPoint ( (set_on) , 30 , random(170-230) ); // fades light up to 66-90% 10 min et.
Channels[0].AddPoint ( (set_on) , 32 , 0 ); // fades light down to 0% (off) over the next 2 min
Thanks.
MultiChannel_PWM_LED_light_control.ino (11.3 KB)
ChannelManager.cpp (5.33 KB)
ChannelManager.h (1.23 KB)