How to make an animation slow down?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Stevan Petrov
    New Member
    • Jan 2011
    • 1

    #1

    How to make an animation slow down?

    I wrote a code based on increasing number to some number...and after reaching it,it displays some text...but whatever number I put(50 or 50000000) it changes during the same time!
    But should it be as bigger number is ,time will be longer,right?
  • horace1
    Recognized Expert Top Contributor
    • Nov 2006
    • 1510

    #2
    try using long ints (usually 32 bits numbers) and/or a loop within a loop.
    If the loop does nothing the compiler may optimise it out completly - on microctrollers there is usually a Nop (No operation) instruction to prevent this, e.g.
    Code:
              for(ii=0;ii<1000000L;ii++); Nop();
    e.g. code to blink a LED 10 times
    Code:
        for(j=0;j<10;j++)
            {
            for(ii=0;ii<200000L;ii++) Nop(); // delay
            PORTAbits.RA4=!PORTAbits.RA4;    // invert LED
            }
    if it still does not work post the code

    Comment

    Working...