Go Down

Topic: Multiple Things at Same Time (Read 592 times) previous topic - next topic

billroy

AWOL's guidance on avoiding delay() is the best advice you'll hear.

One way to accomplish what you're after is to use the Run library:
https://github.com/billroy/run -- there's an example of blinking two LEDs there.

After some practice you start thinking in terms of the pattern of breaking your program into parts that can happily run periodically.

-br

ekscden

#6
Nov 28, 2012, 05:16 pm Last Edit: Nov 28, 2012, 05:20 pm by ekscden Reason: 1

AWOL's guidance on avoiding delay() is the best advice you'll hear.

One way to accomplish what you're after is to use the Run library:
https://github.com/billroy/run -- there's an example of blinking two LEDs there.

After some practice you start thinking in terms of the pattern of breaking your program into parts that can happily run periodically.

-br



The only problem I see is, for example, in flickering the light.  It will need certain delays in it to get the proper flicker effect, so this will slow it down enough to stop the cars and other activities on the train layout.  If I was going to just turn things on or off, I could see this working, but do have more control of speeds etc. I don't understand how it can work.  That's why I had thought maybe a Propeller with the multiple cores since I'm not heavily invested in Arduino at this point.

Seems like no matter what technique, I'd be stuck with:
Flicker light by using a loop to fade it up and down
Exit loop and move the car
Enter another loop to manipulate the servo

Grumpy_Mike

Quote
Seems like no matter what technique, I'd be stuck with ....

No you are stuck with non of those.

Quote
It will need certain delays in it to get the proper flicker effect, so this will slow it down enough to stop the cars and other activities on the train layout.

No it won't if you program it correctly. The secret is a state machine of which the blink without delay is a very simple example.

ekscden

Okay, I'll play with that and see if I can get it to work.  Thanks for the info.

holmes4

Take care with the servo lib from the playground as it uses the same pins as the motor shields, if you use it you can't use servos and motors. Of course you can control a servo with code which is very similar to "blink without delay".

Mark

Go Up