(Persistence Of Vision) -- help

mensage post by CrossRoads

There is a way to create a timer based interrupt to perform things on a steady time time interval, ask in the Programming forum about that.
I would just use micros() and blink without delay timing myself.

void loop(){
currentTime = micros();
elapsedTme = currentTime - previousTime; // all time related items are unsigned long
if (elapsedTime >= duration){
previousTime = previousTime + duration; // set up for next display change

// do whatever gets done for updating the display, make sure it takes
// less time to complete than 'duration'

} // end time check
} // end loop


by Naruto

hello, perhaps they remember me, I still have not start this project.

my problem is to calculate the time to paint the entire wheel at a rate "constant."

I problado in different ways, but I can not do it.

you use this function?
interrupts ();
/ / Code ignition internal leds

noInterrupts ();

void setup () {
                   ...
....
..
       attachInterrupt (0, rpm, FALLING);
}


 void rpm(){
                 interruptHit=true;
                 new_time=micros();
                Refresh = (  (( new_time - timeold)- 244841) /160);   //  244841=time it takes the paint arduino,--
                                                                                                               // 160=ray amount
                
                     //   Refresh = ( ( new_time - timeold) /160);
                 if(Refresh<=0){
                 Refresh=0;
                 }
                 timeold =  new_time;
          
          }
		  
		  
		  
		  void loop(){

     if( interruptHit ==true){

            for(uint8_t curPos=0; curPos<160;curPos++ ){

                      for(uint8_t i=0;i<34;i+=1){  //number of pixels

                           PixelColor(i,  ,  R,G,B  ) ;
                    }
   
         ShowsWS2803();
             refreshEnd=micros();
             while((micros() - refreshEnd)< Refresh   ) {;}

         }
                           interruptHit =false;


else{ 
         
                      for(uint8_t i=0;i<nPixel;i++){
         
                                          PixelColor(i, 0,0,0) ;
                                             
                     
                      }
                      loadWS2803();
         
               }

}// end loop