]> git.piffa.net Git - sketchbook_andrea/blob - hardware/mesure_cyclic_lenght/mesure_cyclic_lenght.ino
Struct
[sketchbook_andrea] / hardware / mesure_cyclic_lenght / mesure_cyclic_lenght.ino
1 /*
2 Measure the lenght of the Loop cycle.
3 */
4
5 long lastMillis = 0;
6 long loops = 0;
7
8 void setup(){
9   Serial.begin(9600);
10 }
11
12 void loop(){
13   long currentMillis = millis();
14   loops++;
15   
16   /* By doing complex math, reading sensors, using the "delay" function,
17   *  etc you will increase the time required to finish the loop,
18   *  which will decrease the number of loops per second.
19   */
20
21   if(currentMillis - lastMillis > 1000){
22     Serial.print("Loops last second:");
23     Serial.println(loops);
24     
25     lastMillis = currentMillis;
26     loops = 0;
27   }
28 }
29
30