Go Down

Topic: Flickering LED (Read 1 time) previous topic - next topic


There are multiple ways of doing this, once you get better at coding, you'll see just how many ways there are.

I would use If/else statements that way I can change the button state at any time.
Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID


You guys were all so helpful. Thanks so much!


analogWrite(ledPin, y);  // turn the LED on      >>>>  if y=-1 this is the same as y=255 full bright
                                                                      >>>> if y=-255 this is the same as y=0 full off
This function will operate on 0 to 255 and on 0 to -255
Since you were at -1 the LED was full bright for a split second.
When y was was incremented it went from -1 full bright to 0 full off.
Hence there was a short flash when you first pushed the button.

You only set y=0 in  setup() this runs once at the start of the sketch.

the one with y++ leaves me with a final value of 256

No.    y-- gave you the -1
The way you have it in your schematic isn't the same as how you have it wired up!

Go Up