I am totally new to Arduino and need help getting started with some code for a robot I am building. I am starting with 2 servos, both of which will stop at 4 positions, making a total of 16 target positions:
- Servo 1 0 degrees - Servo 2 0 degrees
- Servo 1 0 degrees - Servo 2 20 degrees
- Servo 1 0 degrees - Servo 2 40 degrees
- Servo 1 0 degrees - Servo 2 60 degrees
- Servo 1 20 degrees - Servo 2 0 degrees
- Servo 1 20 degrees - Servo 2 20 degrees
- Servo 1 20 degrees - Servo 2 40 degrees
- Servo 1 20 degrees - Servo 2 60 degrees
- Servo 1 40 degrees - Servo 2 0 degrees
- Servo 1 40 degrees - Servo 2 20 degrees
- Servo 1 40 degrees - Servo 2 40 degrees
- Servo 1 40 degrees - Servo 2 60 degrees
- Servo 1 60 degrees - Servo 2 0 degrees
- Servo 1 60 degrees - Servo 2 20 degrees
- Servo 1 60 degrees - Servo 2 40 degrees
- Servo 1 60 degrees - Servo 2 60 degrees
I need the servos to automatically go to one of the 16 target positions when booted. Then I need to instruct the servos to go to different targets, at different rates of speed and remain at each target location for various amounts of time, i.e.
- Go to target 1 on start up. Stay there for 10 seconds.
- Travel to target 12 in 1.5 seconds. Stay there for 5 seconds.
- Travel to target 16 in .8 seconds. Stay there for 2 seconds.
etc.
etc.
I will need to write a routine that will run about 4 or 5 minutes and then repeat. During that time there will be a couple of movements that will be repeating very frequently. It will be similar to a rapid hammering motion (target #15 to target #16 and also target #1 to target #2)
My thoughts are that because of the limited storage capacity of the chip and the need for a 5 minute routine, that the 16 positions could be set up as functions and then called as needed. Also, could the hammering motions also be set up as functions to be called and looped? Also, would it be best to use millis to keep all of the movements in sync?
I am totally lost. I have been trying to figure this out for 4 days and am no closer now than I was when I started.
Thank You
I really need help.