//Forward declare any custom functions void my_function(); void setup() { set_interval(2000, my_function); } void loop() { think(); act(); } void think() { block_value = weighted_average(neighbor_data); } void act() { set_drive(255); if( block_value > 127) { //Stop toggling directions clear_interval(); } } void my_function() { //This function will be called every two seconds. toggle_directions(); }