Show Posts
|
|
Pages: [1] 2
|
|
1
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: RGB Mixed colour to fade Issue
|
on: January 25, 2010, 03:25:57 pm
|
yay! Thanks digimike! That solves all the problems. The light stays on all the time but the colour comes through. I actually prefer it better this way. It will look better in what i will use it for. Now that this is working, I have been looking around for ways to create a random colour. But how i would like to do it is like this: button 1 pressed ---> makes RGB LED Light up with random colour range in a certain Spectrum. So like if i pressed button1 i would get some shade of blue (teal, turquoise, cyan, skyblue, you get the point) But it would never be the same Blue every time button 1 is pushed until it runs out of possiblities. I have found a code for randomly cyclying though colours but done know how to apply it to my code. and button2 would give me some shade of Orange. I have found a code for randomly cyclying though colours but done know how to apply it to my code. here is the code fro random cycling. if (lightMode == 3) { // randomsize colorNew and step colorPwr to it if (redPwr > redNew) { redPwr--; } if (redPwr < redNew) { redPwr++; } if (greenPwr > greenNew) { greenPwr--; } if (greenPwr < greenNew) { greenPwr++; } if (bluePwr > blueNew) { bluePwr--; } if (bluePwr < blueNew) { bluePwr++; }
// If all Pwr match New get new colors
if (redPwr == redNew) { if (greenPwr == greenNew) { if (bluePwr == blueNew) { redNew = random(254); greenNew = random(254); blueNew = random(254); } } }
// display the colors analogWrite(ledRed, redPwr); analogWrite(ledGreen, greenPwr); analogWrite(ledBlue, bluePwr); delay(20); } }
|
|
|
|
|
3
|
Forum 2005-2010 (read only) / Syntax & Programs / RGB Mixed colour to fade Issue
|
on: January 25, 2010, 12:18:20 pm
|
Hello, The following code works but in a strange way. Button1 Pushed ---> RBG LED Lights up with set value (R=155,G=100,B=50) ----> Delay ----> RGB strip truns to white ??? -------> then fades out. Why does the white light show up? Why doesnt theRGB colour fade out to zero and not take the route which it currently does. Ideally i would like it to light up to a certain colour and then fade from that colour to off. Please help  Its very strange. const int ledPinR = 9; const int ledPinG= 11; const int ledPinB = 10;
const int buttonPin1 = 3; const int buttonPin2 = 4;
int buttonState1 = 0; int buttonState2 = 0;
int redPwr = 0; int greenPwr = 0; int bluePwr = 0; int faderR; int faderG; int faderB;
void setup() { pinMode(ledPinR, OUTPUT); pinMode(ledPinG, OUTPUT); pinMode(ledPinB, OUTPUT); pinMode(buttonPin1, INPUT); pinMode(buttonPin2, INPUT);
}
void loop() { buttonState1 = digitalRead(buttonPin1); buttonState2 = digitalRead(buttonPin2 ); if (buttonState1 == LOW){ //redPwr = 246; //greenPwr = 235; //bluePwr = 0; //analogWrite(ledPinR, redPwr); //analogWrite(ledPinG, greenPwr); //analogWrite(ledPinB, bluePwr); //delay(1000); fade(redPwr,greenPwr,bluePwr,50); }
if (buttonState2 == LOW) { //redPwr = 246; //greenPwr = 235; //bluePwr = 0; //analogWrite(ledPinR, redPwr); //analogWrite(ledPinG, greenPwr); //analogWrite(ledPinB, bluePwr); //delay(1000); fade2(redPwr,greenPwr,bluePwr,50); }
else { analogWrite(ledPinR, LOW); analogWrite(ledPinG, LOW); analogWrite(ledPinB, LOW); } }
void fade(int redFrom, int grnFrom, int bluFrom, int delayTime) { /*for (int r=redFrom, g=grnFrom, b=bluFrom; r>=0; g>=0; b>=0; r-=5, g-=5, b-=5) { analogWrite(ledPinR, r); analogWrite(ledPinG, g); analogWrite(ledPinB, b); delay(delayTime); } */ faderR = 246; faderG = 235; faderB = 0; analogWrite(ledPinR, faderR); analogWrite(ledPinG, faderG); analogWrite(ledPinB, faderB);
delay(1000); for (int fader=255; fader>=0; fader-=5) { faderR -= 4;
faderG -= 5; faderB -= 2;
if (faderR > 0) { faderR = 0; } if (faderG > 0) { faderG = 0; } if (faderB > 0) { faderB = 0; }
analogWrite(ledPinR, faderR); analogWrite(ledPinG, faderG); analogWrite(ledPinB, faderB); delay(delayTime); } } void fade2(int redFrom, int grnFrom, int bluFrom, int delayTime) { /*for (int r=redFrom, g=grnFrom, b=bluFrom; r>=0; g>=0; b>=0; r-=5, g-=5, b-=5) { analogWrite(ledPinR, r); analogWrite(ledPinG, g); analogWrite(ledPinB, b); delay(delayTime); } */ faderR = 100; faderG = 0; faderB = 100; analogWrite(ledPinR, faderR); analogWrite(ledPinG, faderG); analogWrite(ledPinB, faderB);
delay(1000); for (int fader=255; fader>=0; fader-=5) { faderR -= 4;
faderG -= 5; faderB -= 2;
if (faderR > 0) { faderR = 0; } if (faderG > 0) { faderG = 0; } if (faderB > 0) { faderB = 0; }
analogWrite(ledPinR, faderR); analogWrite(ledPinG, faderG); analogWrite(ledPinB, faderB); delay(delayTime); } } void fade3(int redFrom, int grnFrom, int bluFrom, int delayTime) { /*for (int r=redFrom, g=grnFrom, b=bluFrom; r>=0; g>=0; b>=0; r-=5, g-=5, b-=5) { analogWrite(ledPinR, r); analogWrite(ledPinG, g); analogWrite(ledPinB, b); delay(delayTime); } */ faderR = 0; faderG = 150; faderB = 200; analogWrite(ledPinR, faderR); analogWrite(ledPinG, faderG); analogWrite(ledPinB, faderB);
delay(3000); for (int fader=255; fader>=0; fader-=5) { faderR -= 4;
faderG -= 5; faderB -= 2;
if (faderR > 0) { faderR = 0; } if (faderG > 0) { faderG = 0; } if (faderB > 0) { faderB = 0; }
analogWrite(ledPinR, faderR); analogWrite(ledPinG, faderG); analogWrite(ledPinB, faderB); delay(delayTime); }
}
Also someone emailed me this code but it doesnt seem to work! const int ledPinR = 9; const int ledPinG= 11; const int ledPinB = 10;
const int buttonPin1 = 3; const int buttonPin2 = 4;
int buttonState1 = 0; int buttonState2 = 0;
int redPwr = 0; int greenPwr = 0; int bluePwr = 0; int faderR; int faderG; int faderB;
void setup() { pinMode(ledPinR, OUTPUT); pinMode(ledPinG, OUTPUT); pinMode(ledPinB, OUTPUT); pinMode(buttonPin1, INPUT); pinMode(buttonPin2, INPUT);
}
void loop() { buttonState1 = digitalRead(buttonPin1); buttonState2 = digitalRead(buttonPin2 ); if (buttonState1 == LOW){ //redPwr = 246; //greenPwr = 235; //bluePwr = 0; //analogWrite(ledPinR, redPwr); //analogWrite(ledPinG, greenPwr); //analogWrite(ledPinB, bluePwr); //delay(1000); fade(redPwr,greenPwr,bluePwr,50); }
if (buttonState2 == LOW) { //redPwr = 246; //greenPwr = 235; //bluePwr = 0; //analogWrite(ledPinR, redPwr); //analogWrite(ledPinG, greenPwr); //analogWrite(ledPinB, bluePwr); //delay(1000); fade2(redPwr,greenPwr,bluePwr,50); }
else { analogWrite(ledPinR, LOW); analogWrite(ledPinG, LOW); analogWrite(ledPinB, LOW); } }
void fade(int redFrom, int grnFrom, int bluFrom, int delayTime) { /*for (int r=redFrom, g=grnFrom, b=bluFrom; r>=0; g>=0; b>=0; r-=5, g-=5, b-=5) { analogWrite(ledPinR, r); analogWrite(ledPinG, g); analogWrite(ledPinB, b); delay(delayTime); } */ faderR = 246; faderG = 235; faderB = 0; analogWrite(ledPinR, faderR); analogWrite(ledPinG, faderG); analogWrite(ledPinB, faderB);
delay(1000); for (int fader=255; fader>=0; fader-=5) { faderR -= 4;
faderG -= 5; faderB -= 2;
if (faderR > 0) { faderR = 0; } if (faderG > 0) { faderG = 0; } if (faderB > 0) { faderB = 0; }
analogWrite(ledPinR, faderR); analogWrite(ledPinG, faderG); analogWrite(ledPinB, faderB); delay(delayTime); } } void fade2(int redFrom, int grnFrom, int bluFrom, int delayTime) { /*for (int r=redFrom, g=grnFrom, b=bluFrom; r>=0; g>=0; b>=0; r-=5, g-=5, b-=5) { analogWrite(ledPinR, r); analogWrite(ledPinG, g); analogWrite(ledPinB, b); delay(delayTime); } */ faderR = 100; faderG = 0; faderB = 100; analogWrite(ledPinR, faderR); analogWrite(ledPinG, faderG); analogWrite(ledPinB, faderB);
delay(1000); for (int fader=255; fader>=0; fader-=5) { faderR -= 4;
faderG -= 5; faderB -= 2;
if (faderR > 0) { faderR = 0; } if (faderG > 0) { faderG = 0; } if (faderB > 0) { faderB = 0; }
analogWrite(ledPinR, faderR); analogWrite(ledPinG, faderG); analogWrite(ledPinB, faderB); delay(delayTime); } } void fade3(int redFrom, int grnFrom, int bluFrom, int delayTime) { /*for (int r=redFrom, g=grnFrom, b=bluFrom; r>=0; g>=0; b>=0; r-=5, g-=5, b-=5) { analogWrite(ledPinR, r); analogWrite(ledPinG, g); analogWrite(ledPinB, b); delay(delayTime); } */ faderR = 0; faderG = 150; faderB = 200; analogWrite(ledPinR, faderR); analogWrite(ledPinG, faderG); analogWrite(ledPinB, faderB);
delay(3000); for (int fader=255; fader>=0; fader-=5) { faderR -= 4;
faderG -= 5; faderB -= 2;
if (faderR > 0) { faderR = 0; } if (faderG > 0) { faderG = 0; } if (faderB > 0) { faderB = 0; }
analogWrite(ledPinR, faderR); analogWrite(ledPinG, faderG); analogWrite(ledPinB, faderB); delay(delayTime); }
}
|
|
|
|
|
5
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: It WONT STOOOP!
|
on: January 24, 2010, 09:18:15 pm
|
is there any way you could just wack it in for me? this is the code const int ledPinR = 9; const int ledPinG= 11; const int ledPinB = 10;
const int buttonPin1 = 3;
int buttonState1 = 0;
byte redPwr = 0; byte greenPwr = 0; byte bluePwr = 0;
void setup() { pinMode(ledPinR, OUTPUT); pinMode(ledPinG, OUTPUT); pinMode(ledPinB, OUTPUT);
pinMode(buttonPin1, INPUT);
} void loop() { buttonState1 = digitalRead(buttonPin1); if (buttonState1 == LOW){ delay(200); redPwr = 246; greenPwr = 235; analogWrite(ledPinR, redPwr); bluePwr = 0; analogWrite(ledPinG, greenPwr); analogWrite(ledPinB, bluePwr); fade(); // this is what is giving me problems! ******** delay(500); } else { analogWrite(ledPinR, LOW); analogWrite(ledPinG, LOW); analogWrite(ledPinB, LOW); } } void fade(int redFrom=246, int grnFrom=235, int bluFrom=0, int delayTime=25) { for (int r=redFrom, g=grnFrom, b=bluFrom; r>=0; r-=5, g-=5, b-=5) { digitalWrite(ledPinR, r); digitalWrite(ledPinG, g); digitalWrite(ledPinB, b); delay(delayTime); } }
pretty pleaaase!
|
|
|
|
|
6
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: It WONT STOOOP!
|
on: January 24, 2010, 07:39:57 pm
|
Im sorry .. its 12:38 here :/ im tired and i have to get this done by tomorrow Still giving me errors. void loop() { buttonState1 = digitalRead(buttonPin1); if (buttonState1 == LOW){ redPwr = 200; greenPwr = 100; analogWrite(ledPinR, redPwr); bluePwr = 50; analogWrite(ledPinG, greenPwr); analogWrite(ledPinB, bluePwr); delay(1000); fade(); } else { analogWrite(ledPinR, LOW); analogWrite(ledPinG, LOW); analogWrite(ledPinB, LOW); } }
void fade(int 200, int 100, int 50, int 25) { for(int r=200, g=100, b=50, r>=0; r-=5, g-=5, b-=5) { digitalWrite(ledPinR, r); digitalWrite(ledPinG, g); digitalWrite(ledPinB, b); delay(1000); } } *sigh* ! 
|
|
|
|
|
7
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: It WONT STOOOP!
|
on: January 24, 2010, 07:20:28 pm
|
It says " In function 'void loop()': error: too few arguments to function 'void fade(int, int, int, int)" void fade(int redFrom, int grnFrom, int bluFrom, int delayTime) { for(int r=redFrom, g=grnFrom, b=bluuFrom; r>=0; r-=5, g-=5, b-=5) { digitalWrite(ledPinR, r); digitalWrite(ledPinG, g); digitalWrite(ledPinB, b); delay(1000); } }
what figure do i put where? say red = 200 green = 100 blue = 50 Thanks you so much for the code though!!! Just need to get this done.. also will this work with randomized colours? 
|
|
|
|
|
8
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: It WONT STOOOP!
|
on: January 24, 2010, 06:43:50 pm
|
This is the code without fading which works fine. const int ledPinR = 9; const int ledPinG= 11; const int ledPinB = 10;
const int buttonPin1 = 3;
int buttonState1 = 0;
byte redPwr = 0; byte greenPwr = 0; byte bluePwr = 0;
void setup() { pinMode(ledPinR, OUTPUT); pinMode(ledPinG, OUTPUT); pinMode(ledPinB, OUTPUT);
pinMode(buttonPin1, INPUT);
} void loop() { buttonState1 = digitalRead(buttonPin1); if (buttonState1 == LOW){ redPwr = 246; greenPwr = 235; analogWrite(ledPinR, redPwr); bluePwr = 0; analogWrite(ledPinG, greenPwr); analogWrite(ledPinB, bluePwr); delay(2000); } else { analogWrite(ledPinR, LOW); analogWrite(ledPinG, LOW); analogWrite(ledPinB, LOW); } }
|
|
|
|
|
9
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: It WONT STOOOP!
|
on: January 24, 2010, 06:39:02 pm
|
First, there's no reason to read buttonState in setup. You don't use the value, so don't make the call. fair enough... In the light function, ...... i have the values because they will reflect the amount of each indipendant colour. if i put the red pin value at 255 then the colour would come our different. otherwise its seems to freak out. fade function: its fixes I just am so confused with this whole set up. All i want is a button to create a colour and have that colour fade out to off. atm i am failing miserably
|
|
|
|
|
10
|
Forum 2005-2010 (read only) / Syntax & Programs / Re: It WONT STOOOP!
|
on: January 24, 2010, 06:10:38 pm
|
Ok i re wrote the code a bit and now it is just a solid colour when i push the button. It give me the colour i want, and lights up which is good... But im just wanting it to fade out !  const int ledPinR = 9; const int ledPinG= 11; const int ledPinB = 10;
const int buttonPin1 = 3;
int buttonState1 = 0;
byte redPwr = 0; byte greenPwr = 0; byte bluePwr = 0;
void setup() { pinMode(ledPinR, OUTPUT); pinMode(ledPinG, OUTPUT); pinMode(ledPinB, OUTPUT);
pinMode(buttonPin1, INPUT); buttonState1 = digitalRead(buttonPin1);
} void loop() { buttonState1 = digitalRead(buttonPin1); if (buttonState1 == LOW){ redPwr = 246; greenPwr = 235; analogWrite(ledPinR, redPwr); bluePwr = 0; analogWrite(ledPinG, greenPwr); analogWrite(ledPinB, bluePwr);
light(); delay(10); fade(); } else { digitalWrite(ledPinR, LOW); digitalWrite(ledPinG, LOW); digitalWrite(ledPinB, LOW); }
}
void light() { // fade in from min to max in increments of 5 points: for(int fadeValueR = 246 ; fadeValueR <= 246; fadeValueR +=0) for(int fadeValueG = 235 ; fadeValueR <= 235; fadeValueR +=0) for(int fadeValueB = 0; fadeValueB <= 0; fadeValueB +=0) { // sets the value (range from 0 to 255): analogWrite(ledPinR, fadeValueR); analogWrite(ledPinG, fadeValueG); analogWrite(ledPinB, fadeValueB); } }
void fade() { // fade out from max to min in increments of 5 points: for(int fadeValueR = 246 ; fadeValueR >= 0; fadeValueR -=5) for(int fadeValueG = 235 ; fadeValueG >= 0; fadeValueG -=0.5) for(int fadeValueB = 0 ; fadeValueB >= 0; fadeValueB -=10){
// sets the value (range from 0 to 255): analogWrite(ledPinR, fadeValueR); delay(30); analogWrite(ledPinG, fadeValueG); delay(30); analogWrite(ledPinB, fadeValueB); delay(30); } }
|
|
|
|
|
11
|
Forum 2005-2010 (read only) / Syntax & Programs / It WONT STOOOP!
|
on: January 24, 2010, 05:06:09 pm
|
Hello! Im trying to get the RGB LED strip to light up to a certain colour when a press button 1. Then it should fade out And the it should wait for me to push the button again But what happens is ... I push the button it comes on! And doesnt turn off and keeps cycling though the colours! const int ledPinR = 9; const int ledPinG= 11; const int ledPinB = 10;
const int buttonPin1 = 3;
int buttonState1 = 0;
byte redPwr = 0; byte greenPwr = 0; byte bluePwr = 0;
void setup() { pinMode(ledPinR, OUTPUT); pinMode(ledPinG, OUTPUT); pinMode(ledPinB, OUTPUT);
pinMode(buttonPin1, INPUT); buttonState1 = digitalRead(buttonPin1);
// serial for debugging purposes only Serial.begin(9600); } void loop() { buttonState1 = digitalRead(buttonPin1); if (buttonState1 == LOW){ redPwr = 255; bluePwr = 125; analogWrite(ledPinR, redPwr); greenPwr = 100; analogWrite(ledPinG, greenPwr); analogWrite(ledPinB, bluePwr);
lightAndFade3(); } else { digitalWrite(ledPinR, LOW); digitalWrite(ledPinG, LOW); digitalWrite(ledPinB, LOW); }
}
void lightAndFade3() { // fade in from min to max in increments of 5 points: for(int fadeValueR = 255 ; fadeValueR <= 255; fadeValueR +=5) for(int fadeValueG = 125 ; fadeValueG <= 125; fadeValueG +=5) for(int fadeValueB = 100 ; fadeValueB <= 100; fadeValueB +=5) { // sets the value (range from 0 to 255): analogWrite(ledPinR, fadeValueR); analogWrite(ledPinG, fadeValueG); analogWrite(ledPinB, fadeValueB); delay(30); }
// fade out from max to min in increments of 5 points: for(int fadeValueR = 255 ; fadeValueR >= 0; fadeValueR -=5) for(int fadeValueG = 125 ; fadeValueG >= 0; fadeValueG -=5) for(int fadeValueB = 100 ; fadeValueB >= 0; fadeValueB -=5){
// sets the value (range from 0 to 255): analogWrite(ledPinR, fadeValueR); analogWrite(ledPinG, fadeValueG); analogWrite(ledPinB, fadeValueB); // wait for 30 milliseconds to see the dimming effect delay(30); } }
Any suggestions! Please!
|
|
|
|
|
12
|
Forum 2005-2010 (read only) / Syntax & Programs / Problem with declaring void
|
on: January 24, 2010, 09:08:10 pm
|
Wont let me declare fade! const int ledPinR = 9; const int ledPinG= 11; const int ledPinB = 10;
const int buttonPin1 = 3;
int buttonState1 = 0;
byte redPwr = 0; byte greenPwr = 0; byte bluePwr = 0;
void setup() { pinMode(ledPinR, OUTPUT); pinMode(ledPinG, OUTPUT); pinMode(ledPinB, OUTPUT);
pinMode(buttonPin1, INPUT);
} void loop() { buttonState1 = digitalRead(buttonPin1); if (buttonState1 == LOW){ delay(200); redPwr = 246; greenPwr = 235; analogWrite(ledPinR, redPwr); bluePwr = 0; analogWrite(ledPinG, greenPwr); analogWrite(ledPinB, bluePwr); fade(); // this is what is giving me problems! ******** delay(500); } else { analogWrite(ledPinR, LOW); analogWrite(ledPinG, LOW); analogWrite(ledPinB, LOW); } } void fade(int redFrom=246, int grnFrom=235, int bluFrom=0, int delayTime=25) // this is the void which i am trying to set up ! { for (int r=redFrom, g=grnFrom, b=bluFrom; r>=0; r-=5, g-=5, b-=5) { digitalWrite(ledPinR, r); digitalWrite(ledPinG, g); digitalWrite(ledPinB, b); delay(delayTime); } } Where is the problem?!
|
|
|
|
|
13
|
Forum 2005-2010 (read only) / Interfacing / Arduino: Sound Input to Light Output
|
on: January 14, 2010, 03:07:20 pm
|
|
Hello everyone! I'm a Product design student at the Edinburgh College of Art (UK) and I have an show coming up soon!
I am wanting to create a string instrument ( Which is integrated ina wooden framed cube) in which I would like the Arduino chip pick up the vibrations by the use of a Guitar pickup.
I would the like the Arduino to translate the pitch and volume to different colours on RGB LED strips (12 Strips Total) The pitch or key would be translated into different colours which are preassigned or it can be random. The Volume would be translated into LED brightness.
So you play these strings and different colours will fade in or out on the RGB LED strips.
If anyone knows: What RGB LED Strips to get What coding to use for the Arduino Anything else I need to get to make this Possible!
Thanks !!! Time is running out!!! Victor
|
|
|
|
|
15
|
Forum 2005-2010 (read only) / Frequently-Asked Questions / Overlapping Outputs
|
on: January 24, 2010, 09:22:09 am
|
Hello this is my code at the moment ( i will expand it to more buttons but at the moment its 2 different inputs and 2 different outputs.) At the moment its press button 1 ---> light LED 1 ---> LED fades out. and the same for button 2 but LED 2 lights. I am trying to figure out a way so i dont have to wait for operation 1 to finish so i can press the next button. So say button1 has been pushed and the light is fading out, i would like to press button 2 to jump on top of button1's remaining function So when LED 1 is fading out LED2 can start on top of LED1 while letting LED 1 fade out. This is my code const int buttonPin1 = 2; const int buttonPin2 = 4;// the number of the pushbutton pin const int ledPin1 = 11; const int ledPin2 = 9; int buttonState1 = 0; int buttonState2 = 0; void setup() { // initialize the LED pin as an output: pinMode(ledPin1, OUTPUT); pinMode(ledPin2, OUTPUT); //nitialize the pushbutton pin as an input: pinMode(buttonPin1, INPUT); pinMode(buttonPin2, INPUT); } void loop() { buttonState1 = digitalRead(buttonPin1); buttonState2 = digitalRead(buttonPin2); // check if the pushbutton is pressed. // if it is, the buttonState is HIGH: if (buttonState1 == HIGH) { digitalWrite(ledPin1, HIGH); myDelay1(); lightAndFade(); } else{ digitalWrite(ledPin1, LOW); } if (buttonState2 == HIGH) { digitalWrite(ledPin2, HIGH); myDelay2(); lightAndFade2(); } else{ digitalWrite(ledPin2, LOW); } } void myDelay1() { delay(100); } void myDelay2() { delay(100); } void lightAndFade() { // fade in from min to max in increments of 5 points: for(int fadeValue = 255 ; fadeValue <= 255; fadeValue +=5) { // sets the value (range from 0 to 255): analogWrite(ledPin1, fadeValue); // wait for 30 milliseconds to see the dimming effect delay(0); } // fade out from max to min in increments of 5 points: for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { // sets the value (range from 0 to 255): analogWrite(ledPin1, fadeValue); // wait for 30 milliseconds to see the dimming effect delay(100); // Your working LED fading code } } void lightAndFade2() { // fade in from min to max in increments of 5 points: for(int fadeValue1 = 255 ; fadeValue1 <= 255; fadeValue1 +=5) { // sets the value (range from 0 to 255): analogWrite(ledPin2, fadeValue1); // wait for 30 milliseconds to see the dimming effect delay(30); } // fade out from max to min in increments of 5 points: for(int fadeValue1 = 255 ; fadeValue1 >= 0; fadeValue1 -=5) { // sets the value (range from 0 to 255): analogWrite(ledPin2, fadeValue1); // wait for 30 milliseconds to see the dimming effect delay(100); // Your working LED fading code } } Would much appreciate it !! Thanks, Victor
|
|
|
|
|