Hi ! I am a starter & would like program for the following requirement.
I want to give Four Inputs -
Rate (Cycle Time) at which the Blinking Starts ( All LED's to Start together for every Cycle Start time)
Different LED ON Times for 3 LED's in Seconds. This time will NOT Be Greater than the Cycle time set.
Eg.: Say Rate (Cycle Time) is Blink every 2 Seconds, With the ON Time for LED-1 = 0.5 Sec,
LED-2 = 1 Sec & LED-3 = 1.2 Sec. Here the ON time of any LED is NOT >= the Cycle time of 2 Sec.
Result Expected = All 3 LED's Should turn ON at Once at each Cycle time of 2 Seconds --> The LED-1 to
be ON for 0.5 Sec & turn off, stay off till next cycle time, LED-2 to be ON for 1 Sec & turn off, stay off till next cycle time arrives, LED-3 to be ON for 1.2 Sec & turn off, stay off till next cycle time.
At Next Cycle time ( At end of 2 Seconds ) All three LED's should repeat the same sequence in loop.
Want to connect 4x4 Keyboard & 16x2 LCD for setting.
To begin, connect only your 4 LEDs but not the keypad and LCD. Write a simple sketch to switch your LEDs on and off as you described in your example. I would recommend avoiding use of the delay() function, because it will probably cause problems later when you add your keypad & LCD. Instead of delay(), use millis() for timing. I would also recommend to use arrays to hold the pin numbers of the LEDs, and the on-times of the LEDs.
I have been trying using millis() but facing a problem - The first time all LEd's start simultaneously & keep up their On times but then later they keep on adding up their own times resulting in their own sequence.
I want all the LED's to go ON at the Cycle times only & turn OFF as per their own ON times set.
Please guide.. Sir, If you have something written up please let me know..
So you write the code that way. You have a cycle timeout that sets all the LEDs on and resets all the LED timeout counters. Then each LED waits out its cycle time and turns off when that time expires.
If you want to discuss code, then post the code you have used for criticism. Read the instructions (point 7) first on how to post the code.