Running 2 pwm pins at the same time problem

I want to be able to fade leds a certain way. What I'm trying to do is fade led1 on from 0 to 255 and then fade it off from 255 to 0. I don't have a problem with that.

My problem is making led2 start fading on when led1 reaches ~30. Every time I try doing this, it ends up stopping led1 and everything else is erratic.

Any ideas on how I could do this?

Post your code. Let's see if we can figure out why things are spazzing on you.

everything spazzes out

That's not a very nice term. Please don't use it.

intr.v., spazzed, spazz·ing, spazz·es.
To be clumsy or inept.

No. There’s absolutely nothing wrong with that phrase how I used it.

FusiveResonance, unfortunately I don’t exactly have the code anymore.
I’ll see what I can conjure up in regards to the original code, but I was sorta hoping there would be a straight forward answer as to how to do this haha.
I’ll post back when I write up the code again.

Edit:
Okay, I kinda figured this wouldn’t work but I tried anyway.

const int led1 = 3;
const int led2 = 5;
const int led3 = 6;
const int led4 = 9;
int fadeon;
int fadeoff;

void setup(){
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(led3,OUTPUT);
pinMode(led4,OUTPUT);
}

void loop(){
for(fadeon = 0; fadeon <=255; fadeon +=5){
analogWrite(led1,fadeon);
delay(1);
}
for(fadeoff = 255; fadeoff >=0; fadeoff -=5){
analogWrite(led1,fadeoff);
delay(1);
if(fadeoff <=30){
continue;
for(fadeon = 0; fadeon <=255; fadeon +=5){
analogWrite(led2,fadeon);
delay(1);
}
for(fadeoff = 255; fadeoff >=0; fadeoff -=5){
analogWrite(led2,fadeoff);
delay(1);
if(fadeoff <=30){
continue;
for(fadeon = 0; fadeon <=255; fadeon +=5){
analogWrite(led4,fadeon);
delay(1);
}
for(fadeoff = 255; fadeoff >=0; fadeoff -=5){
analogWrite(led4,fadeoff);
delay(1);
if(fadeoff <=30){
continue;
for(fadeon = 0; fadeon <=255; fadeon +=5){
analogWrite(led3,fadeon);
delay(1);
}
for(fadeoff = 255; fadeoff >=0; fadeoff -=5){
analogWrite(led3,fadeoff);
delay(1);
}
}
}
}
}
}
}
}

Logically speaking, it seems like it should work to me. Although, I’m kinda new at this still.
Using this, LED1 just keeps fading on and off.

No. There's absolutely nothing wrong with that phrase how I used it.

It's the etymology that is offensive.

Pspkicks I don't know where in the world you are but that is an offensive word. It is a contraction of spastic which has for a long time been used as a term of abuse likening people to people suffering certain motor neuron conditions. It is now one of those unacceptable words in a similar way to the N... word to refer to black people is now totally unacceptable.

I dont know what part of the world you 2's sensitive ears are in, but heck I heard it just the other night on network tv

I get abit touchy on things like this, I once spent nearly 3 weeks defending my self because I called someone a dumbass on MY OWN FORUM and was being herassed by many people for being a raciest!

If you have an issue with something someone writes PLEASE do us all a favor and telly us why, and not just demand we dont do it (thanks GM for taking the time to write more than a half sentence)

Well, I'm in the US. I'm sure that explains everything (We're so screwed up here, honestly). ;D

I'm sorry for offending anyone. I'll edit my first post and refrain from using that word. I didn't think it would be offensive, especially considering I was referring to lights... Generally here it's used, for example, when someone tickles someone or pokes them in a sensitive spot (right above one's hips, for example) and they "spaz out".

Back on topic, now that we've cleared this up lol

Oh, side note. Does anyone have a pinout of the wii remote PixArt sensor?

and not just demand we dont do it

@Osgeld I'm guessing English is not your first language, so I apologise, but you'll note that I didn't "demand", I used the word "please".

I'm truly depressed that you heard the word on network TV, though I'm puzzled why anyone would think "dumbass" racist. "Equinist" maybe (if that's a word), but not "racist"

Get back on topic. Now. See, that's demanding.

Can you PLEASE go be "depressed" somewhere else? I'm trying to ask for help and all you're doing is pissing and moaning about a commonly used word. It's used on TV all the time. Grow a pair and realize this is the real world. It doesn't center around yourself.

This is my thread, and I'm asking you to leave. Don't post again unless you're willing to help me with my problem. I already edited my first post and removed the word to please you. I can just as easily put it back in.

OK, back on topic. Check scope rules.

I'm trying to ask for help and all you're doing is pissing and moaning about a commonly used word

You see? That's the really sad thing, that coarse words like "pissing" can enter the language too, and be thought acceptable.

Pissing and moaning is a phrase synonymous to complaining. If you don't like it, leave.

Pissing and moaning is a phrase synonymous to complaining

Really? "urinating" == "displeasure"

Interesting evolution of language.

(Hint: excessive use of "continue")

I suggest we all leave his thread. See where that leaves him.

Interesting way this topic has gone...

For the record, I'm from the US and American English is my native language. Never have I ever in my entire life heard of anyone who found "spaz" (or however you want to spell it) to be offensive. NEVER. So I guess I could see the original poster's frustration there. As for the other offensive word (piss)... Well, some people find it offensive, some do not. It's not really considered too much of a bad word in the US. Growing up I knew several people whose parents let them use that word. Strangely, sometimes those same people found "crap" to be an offensive word. Not my parents...

But this brings up an important point. Sometimes words not offensive in one locale will be offensive in others. For instance, bloody is not a bad word in the US (in any context) but supposedly can be in England. It can be really tough to know what to say to certain people because some people talk like dock workers and other people talk like the Pope.

Anyway, regardless the original poster's attitude does seem to need adjustment if they ever hope to get any help.

The only reason why I have an attitude is because you're all fighting with me over 1 stupid word while I came here asking you all for help.

You completely turned this topic from a simple question into a fight against me.

I guess I was wrong about this place having a nice community.

It IS a nice community. But, in a nice community, if someone says "I find that word offensive, please don't use it", you don't get defensive. You say "OK. I'm sorry to have offended you". That "nice community" works both ways.

To answer your original question, you have to use just one for loop to ramp up and back down. In that for loop, you need to look at the index, and determine whether or not to turn on (or up) or off (or down) each LED.

Do you want to just run one up and back down 30 steps behind the other one time, or do you want the leds to fade up and down endlessly, always 30 steps out of phase?

Uhm. Well, neither. I want led2 to start fading on once led1 reaches 30 while fading off.

My code is terrible, I'm still learning lol

But, do you want this to happen once, or over and over.

In other words, fade led1 on, then off. When it is nearly off, start fading led2 on. Fade 2 up and 1 down, until 1 is off. Continue fading 2 on, then off. Then, you're done.

Or do you want 1 to start fading again?