More than an Hour Timer

Project tutorial by Ian Cumming

  • 1 comment
  • 5 respects

Musical Fairy Lights

Project tutorial by Ian Cumming

  • 13 respects

One Pixel Thermometer

Project tutorial by Ian Cumming

  • 8 respects

Toolbox 2

Respected projects 0

 Ian Cumming hasn't respected any projects yet.
  • A Simple Arduino Menu With An LCD almost 2 years ago

    See Mr_Glenn's comment.

  • A Simple Arduino Menu With An LCD almost 2 years ago

    Hi, Well done on your debugging! I think I might have pinned down the problem (from your code changes and explanation) .

    The "if (brightness <= 0 || brightness >= 255) {fadeAmount = -fadeAmount;} " doesn't know which direction the brightness is going. When the brightness value is 255 after the blink or "On" , the fadeAmount is at -5 sometimes.
    The if statement checks the brightness value and sees that it is >= 255. It sets fadeAmount to +5. In next iteration of the function brightness is 260 and sets fadeAmount to -5. Brightness is then set at 255 it then increases brightness again to 260 forever going into a endless spiral of doom and despair . Hence it going from 255 to 260 and back again.

    A little less code would be to set the brightness value to 128. (Line 82) It would not then get caught in the 255-260 loop.

    I'm not sure if the operator "-" is considered a function. I use operators within abs all the time and have not come across any issues with it.

    PS. I literally gave myself a facepalm on not setting the type.

  • A Simple Arduino Menu With An LCD almost 2 years ago

    I've updated the code with your error findings. I did not test it but theoretically it should work properly now.
    1. The timer variable should be an "unsigned long" as the timer itself is an unsigned long type. This will sort the glitch with the fade. (It was fading very fast)
    2. Added a const to hold the number of buttons.
    3. Corrected the pin assignments. (and added comments for the extra pin.

    Thank you for your feedback on the projects. You have made it better!

Add projectSign up / Login