Hi Everyone,
I am trying to write the code where two leds blink and one led fades. It is combining the two Arduino tuts but I want them to run for ten minutes or until power is off.
I just can't get my mind around writing the condition - while, do while, if ...
please help me back on the road. I've had enough issues just getting my Unos to work.
Attached is my code.
Thank you.
Mike
/*
Fade
This example shows how to fade an LED on pin 9
using the analogWrite() function.
This example code is in the public domain.
*/
int sionMax = 100;
int sionValue = 0;
int brightness = 0; // how bright the LED is
int fadeAmount = 1; // how many points to fade the LED by
void setup() {
// declare pin 9 to be an output:
pinMode(9, OUTPUT);
// declare pin 8 is left eye
pinMode(8, OUTPUT);
//declare pin 7 is right eye
pinMode(7, OUTPUT);
}
void loop() {
while(sionValue < sionMax)
//loop to blink eyes
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
delay(50);
digitalWrite(8,LOW);
digitalWrite(7,LOW);
delay(5200);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
delay(100);
digitalWrite(8,LOW);
digitalWrite(7,LOW);
delay(3200);
// end to blink eyes
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness == 0 || brightness == 60) {
fadeAmount = -fadeAmount ;
sionValue = sionValue + 1;
}
// wait for 30 milliseconds to see the dimming effect
delay(40);
}