WAIT FUNCTIONS

I'm trying to get an animatronic project with 3 motors to the point where I can code each servo to move and wait as I please. Currently all I can do is make the motors randomly go back and forth. How do I input wait functions? Movement functions? not just this stupid void loop of movement. Thanks for the help

How do I input wait functions? Movement functions?

You type functions using a text editor, and then you use a compiler and linker to create an executable.

You might be wanting to enter wait DATA (how long to wait) and movement DATA (what to move how much).

not just this stupid void loop of movement.

Stupid functions are written by stupid programmers. Since you are calling loop() stupid, and you wrote it, that doesn't reflect well on you.

ArduinoTHOTTY:
I'm trying to get an animatronic project with 3 motors to the point where I can code each servo to move and wait as I please. Currently all I can do is make the motors randomly go back and forth. How do I input wait functions? Movement functions? not just this stupid void loop of movement. Thanks for the help

You show us what you have so far, stupid or not. You tell us what it does. Then you tell us in detail what you want it to do that's different and what you've tried.

Detail and planning is really all it takes.

Steve

ArduinoTHOTTY:
I'm trying to get an animatronic project with 3 motors to the point where I can code each servo to move and wait as I please. Currently all I can do is make the motors randomly go back and forth. How do I input wait functions? Movement functions? not just this stupid void loop of movement. Thanks for the help

6 years of Arduino and you don't know how to time events yet? Or 6 years since you started with Arduino and never really did much?

The stupid void loop, aka the main loop is key to making real world code work. The fun part is making things work smoothly together rather than like moves on a chess board.

Learn about state machines. You can move any number of servos in a coordinated way if they each take tiny little steps towards their destinations and you make tens or hundreds of steps per second.

Have a look at how millis() is used to manage timing without blocking in Several things at a time.

And see Using millis() for timing. A beginners guide if you need more explanation.

...R

GoForSmoke:
6 years of Arduino and you don't know how to time events yet? Or 6 years since you started with Arduino and never really did much?

The stupid void loop, aka the main loop is key to making real world code work. The fun part is making things work smoothly together rather than like moves on a chess board.

I know actually more then u think, u don't know me but I did arduino at Georgia tech. I'm a little rusty because that was years ago and i'm at oxford now where we don't do arduino as i'm not taking any of the classes that would feature arduino. I don't know what a milli is, pls explain. thanks!

I don't know what a milli is

Says it all.

Did you look at the links posted by Robin2 in reply #5 ?

ArduinoTHOTTY:
I know actually more then u think, u don't know me but I did arduino at Georgia tech. I'm a little rusty because that was years ago and i'm at oxford now where we don't do arduino as i'm not taking any of the classes that would feature arduino. I don't know what a milli is, pls explain. thanks!

The 6 years part is because I was sure that is not 6 years continuous work with it, not if you're bright.

The millis() and micros() functions return 32 bit unsigned time since startup.
Neither is just what the name implies.

The millis return low 8 bits skips 6 values including 0xFF as a way to make 250usec fit into count of 256. The rub is that you can take 2 time marks and not know if subtracting start-millis from end-millis will be 1 high or low or the right value without more code checking the low bits to find out. The answer is simple: don't use millis if you have to be closer than 1 to correct.

The micros return is granular to 4. It's an 8 bit machine and those are 4 byte values, and 4usec is 250x closer than 1msec.

In the Arduino Playground there are techniques to measure closer based on clock and instruction cycles. I have found that it's possible to watch a pin in a count loop that takes about 1usec per pass.

Always use unsigned values for timing. Always subtract start time from end time to get the difference. Always use time variables that can hold more than the longest interval you may time. Other than that, using 8 or 16 bit time values will run faster than 32 bit and use less RAM and flash.

The news in physics seems to be getting more and more interesting. If we get cheap fusion there will be enough energy to cook the ecosphere right in time for our extra-thick greenhouse blanket to hold tight. Is there any way to keep greed from making that happen as the race to burn everything has done so far? Problem for your time, I guess, since there's no way the knowledge will not get out so maybe find cooler solutions to package along or say hello to the next great extinction.

Robin2:
Have a look at how millis() is used to manage timing without blocking in Several things at a time.

And see Using millis() for timing. A beginners guide if you need more explanation.

...R

thanks for the help!

If you want a fully fledged project to copy then this is what I did about 4 years ago.

It is for a Raspberry Pi controller and was published in the MagPi magazine No 38 - available as a free download.

The code is in Python but it is quite C like in its structure. The main code simply manipulates various motors and LEDs from the keyboard. But in the Git Hub pointed at in the article there is also "Mulder Script" which reads from a text file to perform any actions without resorting to writing code. The opening sequence of the video shows an example of a script running.

http://forum.arduino.cc/index.php?topic=611803.0

Three motors. Animatronics. Coding trouble. Both posting from Sarasota County Schools.

Which is the sock puppet?