Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* run different tasks at different intervals on Arduino without
- * interrupts or blocking/delay
- */
- void loop()
- {
- int now = millis(); /* no sense in calling millis over and over */
- /* this runs at 1/10ms = 100Hz */
- if ( (now % 10) == 0) { /* short, frequent tasks at top */
- readGyro();
- }
- /* 1/50ms = 20Hz */
- if ( (now % 50) == 0) {
- readCompass();
- }
- /* this runs whenever there's a character available */
- /* possibly parsing GPS as well ala TinyGPS */
- if ( Serial.available() ) {
- readGPS();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement