Go Down

Topic: Constant voltage in a PWM pin (pin 6) (Read 1 time) previous topic - next topic


Ok, I've edited the first one (it doesn't really leap of the screen, it just kinda surreptitiously stays there, lurking, waiting to crash the compiler and laugh an evil laugh...) :D

Now the second one I don't see what the problem is. I want i to start at 255, and decrease by 1 while it's bigger than 0. What's wrong with that?


What's wrong with that?

Nothing wrong, per se, but the "up" loop goes 0...255, whilst the "down" goes 255...1

I guess I like symmetry (and I'm a pedant)

it's like these two lines in the servo sweep example
Code: [Select]
for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees

- my blood-pressure rockets every time I see them cut-and-'pasted somewhere.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.


Fair enough. But since that wasn't the software used, I just wanted to demonstrate that the LED would get an up-n-down motion, it wasn't really important if it would go to 0 or 1 (the voltage with 1 is pretty much the same as with 0)...

Go Up