Hi there everyone,
Before i explain what i am trying to achieve let me first please say i am new to arduino (and programming), so please be kind.
I am starting to write code for a autonomous boat. I have gotten each component working individually and am now working on the code and calculations to get them to work together.
I have a gps, compass, servo for rudder, servo for sail (sail servo not implimented yet, going to start with a electric boat rather than sail boat) and a motor.
What i would like to do is to ask the coding to call the gps say every 5mins then steer the boat via the compass for the remaining time, so my question is what's the best way of doing this?
Do i simply write a "void GPS_course" script, then calculate the number of loop's it takes for 5 mins then say
if (number_of_loops=5mins)
{void GPS_course;
i=0;
};
obviously having replaced "5mins" for a predetermined number of loops, which would be counted by
i = ++i
and the value of "i" reset inside the if statement.
I'me sure there is a more elegant solution, i just don't know what it is.