zoomkat:
You need to add (say) delay(50); as the last thing in loop(). And you shouldn't use delay() in your real code - just for this demo.
New code should be based on using Millis and not delay. Maybe a little more complex, but probably better control.
How would that look?
I am learning as I go here, and THANK YOU!!! For the help!
Here is your code Robin2:
Here is a mod to go in reverse:
/*
August 24th 2014
Version 1.2 Firmware development for the open source "Lite Arm" Project:
http://www.thingiverse.com/thing:407800
Check the end of this code for a list of people who contributed to this project
*/
//Robin2's code modified to move arm forward from a home position, other
//mods are in the delay and steps
// "define global variables"
#include <Servo.h>
Servo servoBase;
Servo servoShoulder; //assign names to the servos
Servo servoForearm;
int servoBasePos = 1500;
int servoShoulderPos = 1500;// variable to store the servo (start) position
int servoForearmPos = 1500;
void setup()
{
servoBase.attach(9, 1000, 2000); // Set servo to pin 9, min, max
servoShoulder.attach(10, 1000, 2000); // Set servo to pin 10, min, max
servoForearm.attach(11, 1000, 2000); // Set servo to pin (11, min, max);
moveLimbs(); // to the initial position
delay(1000); // so we can see the initial position
}
void loop() {
updateLimbPositions();
moveLimbs();
delay(40);
}
void updateLimbPositions() {
// run in reverse of last code
servoBasePos -= 11; // microsecs
servoShoulderPos -= 11;
servoForearmPos -= 11;
if (servoBasePos < 1100) {
servoBasePos = 1100;
}
if (servoShoulderPos < 1100) {
servoShoulderPos = 1100;
}
if (servoForearmPos < 1100) {
servoForearmPos = 1100;
}
}
void moveLimbs() {
servoBase.writeMicroseconds(servoBasePos);
servoShoulder.writeMicroseconds(servoShoulderPos);
servoForearm.writeMicroseconds(servoForearmPos);
}
/*
August 24th 2014
Version 1.0 Firmware development for the open source "Lite Arm" Project:
http://www.thingiverse.com/thing:407800
Contributors:
Senior hardware design, instigator, and co-founder: Lance Pierson www.armatecgroup.org
Design inspiration from the uArm project:
https://www.kickstarter.com/projects/ufactory/uarm-put-a-miniature-industrial-robot-arm-on-your
The U Factory team:
Frank Zhang, Evan Deng, Aler Gu, Loeve Le, James Wang & Eric Wang.
Hardware 3D printing, testing and ebay parts supply:
Mark Jansen (http://www.thingiverse.com/mjansenoh/about) (http://www.ebay.com/itm/Lite-Arm-Open-Source-Arduino-Robotic-Arm-Structural-Parts-Kit-/221527649285?)
Joel Brown (Hardware printing and testing) (http://www.thingiverse.com/chphead24/about)
Code development contributors
Arduino Forum:
Robin2 (Code for initial servomotor smoothing) (http://forum.arduino.cc/index.php?action=profile;u=174714)
Zoomcat (insiration for GUI) (http://forum.arduino.cc/index.php?action=profile;u=18664)
*/
And a mod to the original code in video 8.24.14_A changing the start and end positions, to make movement a little smoother, and step in sync.
// "define global variables"
#include <Servo.h>
Servo servoBase;
Servo servoShoulder; //I assume that I add this the same way
Servo servoForearm;
int servoBasePos = 1100;
int servoShoulderPos = 1100;// variable to store the servo position
int servoForearmPos = 1100;//if i dont add the above i get thee error below
void setup()
{
servoBase.attach(9, 1000, 2000); // Set servo to digital pin 9, min, max
servoShoulder.attach(10, 1000, 2000); // Set servo to digital pin 10, min, max
servoForearm.attach(11, 1000, 2000); // Set servo to digital pin 11, min, max
moveLimbs(); // to the initial position
delay(1000); // so we can see the initial position
}
void loop() {
updateLimbPositions();
moveLimbs();
delay(40);
}
void updateLimbPositions() {
// this is just simple demo stuff
servoBasePos += 15; // microsecs
servoShoulderPos += 15;
servoForearmPos += 15;
if (servoBasePos > 1500) {
servoBasePos = 1500;
}
if (servoShoulderPos > 1500) {
servoShoulderPos = 1500;
}
if (servoForearmPos > 1500) {
servoForearmPos = 1500;
}
}
void moveLimbs() {
servoBase.writeMicroseconds(servoBasePos);
servoShoulder.writeMicroseconds(servoShoulderPos);
servoForearm.writeMicroseconds(servoForearmPos);
}
How would I combine these two versions of code to make the arm move as shown in the second video without me uploading two sets of code?