Hey Mates,
I wanted to simulate the Dawn light with my arduino Uno using array implementation.
I desired to change the brightness of the LEDs using fade effect( Smoothly and keep it unchanged until the next function called out) from 0 brightness to specific values in array ( it means specific brightness for each LED).
I wrote my code and compiled it but unfortunately nothing happens when I upload it to my device.
The device is already connected and I have tested some other on/off led codes.
Here is my pre-code:
//Dawn Light Simulation
int LEDArray[] = {3, 5, 6, 9, 10, 11};
int LedNum = 6;
int i;
int j;
int Dawn[] = {30, 20, 20, 20, 100, 0};
int Current[] = {0, 0, 0, 0, 0, 0};
unsigned long time_for_fadestep;
#define Fade_Interval 1200;
void setup() {
for (int i = 0; i < LedNum; i++)
pinMode(LEDArray[i], OUTPUT);
}
void DawnMode()
{
if (millis() > time_for_fadestep) {
time_for_fadestep = millis() + Fade_Interval;
for (int j = 0; j < LedNum; j++){
if (Dawn[j] > Current[j]) Current[j++];
if (Dawn[j] < Current[j]) Current[j--];
analogWrite(LEDArray[j], Current[j]);
}