chipKIT® Development Platform

Inspired by Arduino™

multithreading

Created Sun, 22 Jan 2012 12:17:35 +0000 by yoshco


yoshco

Sun, 22 Jan 2012 12:17:35 +0000

i think i've heard this is coming anyways, but for now i could use some help porting this lib. http://arduino.cc/forum/index.php?topic=66062.0

BTW. this elapsed.h lib seems to work ok http://www.gammon.com.au/forum/?id=11094

if (t2.intervalMs () > 200)   // time up?
    {
    digitalWrite(2, !digitalRead (2));   // toggle the LED
    t2.reset ();   // reset the timer
    }  // end if time up

slayer1991

Sun, 22 Jan 2012 14:08:39 +0000

I do it like this

int time1X=0,oldtimeX=0,x=0;
void loop()
{timeX=millis();
if(timeX>=(oldtimeX+200))
{x++;
oldtimeX=timeX;}
}

if you want to do 2 things like on and off a led, add another variable and an if: c=0 do that and c++, c=1 do the other thing and c--.