Hi...
First, a comment on coding style that may be helpful and save you unnecessary trouble in the future...
Rather than writing your code like this:
if (mode == 3) // Corrected, as per suggestion in earlier post
analogWrite(ledpin3, pot);
else
analogWrite(ledpin3, 0);
I
strongly recommend writing such code using braces such as:
if (mode == 3) { // Corrected, as per suggestion in earlier post
analogWrite(ledpin3, pot);
} else {
analogWrite(ledpin3, 0);
}
Doing this now means you'll never do the following and wonder why the second function is always called:
if (mode ==3)
doSomething();
doSomethingElse();
p.s, why does it ask me for a primary expression before the freaken "else" statement sometimes?
Some example code that causes this problem would be useful in diagnosing what causes it...
--Phil.
P.S. I seem to recall you mentioning in an earlier post that you are currently at school, if you're wanting to get into software development using C/C++ as a career (or just to make you hobby code better) I
strongly suggest you (and anyone else) read the book
Code Complete. Maybe not now, but certainly in the future as it includes good coding style suggestions and better to learn good habits early. Maybe see if your local library has a copy. ("
Writing Solid Code" is also worth reading for similar reasons--in fact it might even be a better, more code-focussed starter--it's been a while since I've read them. :-) ) In my experience any book by either of the "two Steves" (no, not the Apple ones... :-) ) is worthy reading for software developers.