Running methods simultaneously?
bulkhead
Posts: 405
I have two methods- an "openRightArm()" and an "openLeftArm()" method, which increments PWM values in millisecond intervals to a servo, opening the arm in a period of roughly two seconds. Is there a way to get these two methods to run at the same time? Or do I have to combine the two methods into one so that both PWMs are updated in the same loop?
Comments
static Timer t = new Timer();
static boolean armUpdate; //set this boolean when arms need update
static void main() {
· if (armUpdate) {
··· if (t.timeout(1)) { //1 msec timeout
····· t.mark();
····· updateLeftArm();
····· updateRightArm();
··· }
· }
· //other mainloop code here
}
regards peter