Timing 2 LED's to Blink and Flash

New to everything Arduino.
What I’m trying to do is simulate a Lighthouse light, the LED needs to start at a low value then ramp up to max or near max, at this point I need to the LED to blink one time at max then ramp back down. Or use 2 LEDs with one (white) which ramps up to max then have it trigger a second LED (blue) flash one time then the white LED ramp back down then repeat.
Using the Square Wave and Sine Wave Nodes I got both LEDs flashing and blinking. I’m having trouble getting the timing set or having the max sine wave to signal the Flash.

Try using fade node instead of sine to ramp up light. You may need a delay node to do flash. I’m not at computer to see if fade node tells you when it is done.

yeah fade node and flip-n-times node with a delay - thats how I also built myself a custom flash signal

Thanks for the response
In trying to lean xod and Arduino I’m attempting to place one node at a time and uploading with different variables to observe the changes.
So far I have 2 “fade” nodes
Fade-1 = targ - .2, rate - .1, out - 1
Fade-2 = targ - output from fade-1, rate - .1, out - .2
Outcome = LED starts dim, increases to bright, then dims

Next I added a “defer” node, linked from LED “done” to top of defer node, bottom link to Fade-1 UPD, thinking this would start process start again. However this didn’t work for me.
I realize it’s a learning process, figuring which nodes link and why.

Thanks for the response
In trying to lean xod and Arduino I’m attempting to place one node at a time and uploading with different variables to observe the changes.
So far I have 2 “fade” nodes
Fade-1 = targ - .2, rate - .1, out - 1
Fade-2 = targ - output from fade-1, rate - .1, out - .2
Outcome = LED starts dim, increases to bright, then dims

Next I added a “defer” node, linked from LED “done” to top of defer node, bottom link to Fade-1 UPD, thinking this would start process start again. However this didn’t work for me.
I realize it’s a learning process, figuring which nodes link and why.

Did a quick look at the “flip-n-times” node, it will take me awhile to decipher the in and out links, would this replace the second Fade Node?

Your description of what you have configured and your outcome don’t seem to match up, or I’m not understanding what you have configured…

I finally had some time to sit in front of a computer and try to work this out instead of just commenting from memory. Turns out this is unexpectedly hard to configure…

Here is what I finally came up with for dim->bright->flash->[repeat]. I went back to your starting idea of using sine-wave to do the dim/bright cycle. Since it has an enable pin to pause the cycle, I used this to add a flip-n-times to perform the flash. Maybe it was a design decision, but I think it is a bug in flip-n-times: a cycle includes on and off, but for the last cycle, the active pin goes false when the off cycle starts, so I had to use 2 cycles to get 1 flash. Below I use this to my advantage; I use an if-else to pass 0 (LED off) for the on cycle, then 1 (LED bright) for the off cycle, so LED turns off, comes on full-bright, goes off, then continues sine-wave cycle (from brightest point).

So starting at the top, we have flip-n-times to control flash. if-else converts boolean to number for flash values. sine-wave node is only active when we are NOT doing flash. Second if-else node selects value from flash or sine-wave, depending on whether or not flash is active. “> 0.99” checks to see if sine-wave is at its peak (it would be nice to use =1 here, but we are dealing with floating numbers, and two floating numbers are almost never equal, so it would likely never trigger). If sine-wave is at its peak, then we send a pulse to start the flash. In this example, I have a watch node instead of an LED node.

I have not included any of the time settings (for sine-wave or flip-n-times) since they are dependent on pattern you want (or more likely, specified by the Coast Guard or other Naval agency). If you don’t want to use the full [0-1] range of the sine-wave output, you can add a map node to specify range you do want. Where to put it depends on whether or not you want flash limited by map function also.

If you want to flash a 2nd color (assuming white light stays on when blue flashes):

  • delete second if-else
  • feed sine-wave output directly to white LED
  • feed 1st if-else output to blue LED

I think my above response is a more correct answer for this problem, but since I suggested using the fade node, I should probably follow up on that…

The fade node does not have a “done” pin to indicate when the target value has been reached. The “easy, but wrong” solution would be to compare if fade output equals fade target. I say this is wrong because they are floating point numbers, so comparing via “equal” does not work; there is almost always some rounding error that makes them not equal.

There are two ways around this. You can calculate how long it will take to reach the desired target & use a delay node in parallel with with fade node to trigger the next action, or you can use a relative operation to compare fade target and fade output. Probably the easiest generic solution would be to use between and compare output with target +/- some value like this:

image

You can simplify to just greater or less if you know target value and direction of change. For example, if you know you are fading down to 0:

image

Note that I used “0.01” for my “rounding error”. Your project might work with integers, or you might need to use even smaller values like 0.0001. 0.01 is a good value if you are counting between 0 & 1 in steps of 0.1. If you are counting to 100, then > 99 should work; if that skips your last value, then try > 99.5.

These examples only allow you to determine when fade has reached its target…it still doesn’t help with multiple fades. If you are going to include multiple fade nodes, then you need to include a select node to determine which fade node value to use at any time. You also need a way to set initial value of each fade node; if you loop back a second time, all nodes will already be at their target value. An alternative would be to keep changing the target value of a single fade node, but you still need a way to determine what the current target should be, so there will still be a select or some logic & if-else nodes. If rate needs to change as well as target, then things get even messier…

The LED “done” pin fires whenever it has finished an update. This would be after each change in brightness output by the fade node, not when the fade cycle has completed.

The UPD pin on fade indicates when the next “step” should be taken, not when it should start fading and continue until it reaches its target value.

I truly appreciate your time and effort!

I’ll copy your nodes and give it a try. only my second week trying to learn and obtain a base knowledge of electronics and I realize there is much to learn. Guess I’ll step back and work more of the available tutorials.

Thanks