Hello everyone out there who understands coding better than I do.
Plan:
- I want a white LED to fade in and out ONLY ONCE, then turn off (which is the main obstacle in my coding knowledge.... I can't use millis, and also, the "exit(0)" function seems to be against me as well)
- Then, as the white LED starts fading out, a red LED would make this flame effect continuously until the whole system is fed with current. (This effect works pretty nicely so far.... just think there's a better way of approach.
Code:
int red = 3;
int white = 5;
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
void setup(){
pinMode(red, OUTPUT);
pinMode(white, OUTPUT);
}
void loop() {{
analogWrite(white, brightness);
brightness = brightness + fadeAmount;
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
delay(30);
}
analogWrite(red, random(120)+135);
delay(random(50));
}
Thank you SOOO much for any help.... other than that, what book, app, whatever, would you recommend for learning C/C++ effectively?
Have a great day.
Mark