Dear all,
I have tried to run with muy pupils an Arduino project based on a code to move a robotic arm.
The project did run with an older Arduino Uno that I saw, but with several Arduino Uno I bought did not work.
We have checked all the items, and finally I have read if it has some relationship with the chip ATMEL. In both cases, the IDE 2.3.X was used, but the code worked in an older version that I have, which is not working properly.
I received info about the ATMEL older, which works:
MEGA 16U2
2241 TH
2241ESP
And the ATMEL I have, which does not work:
MEGA 16U2
2240 TH
22407JJ
I have checked all the issues, all connections are correct, serv motors and stepper motors are working correctly, and the last issue to consider is that one I comment to you.
Where is the problem. Could anyone help us to continue running the project? I am very grateful.
The code is the following:
//Nombre -> Robot GINER
//Proyecto -> Brazo robótico version1 #include <Servo.h> #include <Stepper.h>
Servo servomotor3; //Servomotor pinza
Servo servomotor2; //Servomotor en medio
Servo servomotor1; //Servomotor abajo
Stepper motor(2048, 4, 6, 5, 7);
void setup() {
servomotor3.attach(11);
servomotor2.attach(10);
servomotor1.attach(9);
motor.setSpeed(5);
}
void loop() {
//Reinicio
servomotor1.write(0);
servomotor2.write(0);
servomotor3.write(0); //motor.step(512);
delay(3000);
//COJE EL OBJETO
for(int i=0; i<=45; i++){
servomotor3.write(i);
delay(25);
}
delay(1000);
for(int i=0; i<=90; i++){
servomotor2.write(i);
delay(25);
}
delay(1000);
for (int i=0; i<=90; i++){
servomotor1.write(i);
delay(25);
}
delay(1000);
for(int i=45; i>=0; i--){
servomotor3.write(i);
delay(25);
}
delay(1000);
for (int i = 90; i>=0; i--){
servomotor1.write(i);
delay(25);
}
delay(1000);
for (int i = 90; i>=0; i--){
servomotor2.write(i);
delay(25);
}
delay(1000);
//GIRA CON EL OBJETO
motor.step(512);
delay(1000);
//DEJA EL OBJETO
for(int i=0; i<=90; i++){
servomotor2.write(i);
delay(25);
}
delay(1000);
for (int i=0; i<=90; i++){
servomotor1.write(i);
delay(25);
}
delay(1000);
for(int i=0; i<=45; i++){
servomotor3.write(i);
delay(25);
}
delay(1000);
//VUELVE A LA POSICION INICIAL
servomotor1.write(0);
servomotor2.write(0);
motor.step(-512);
delay(3000);
}
Please if you need additional information, do not hesitate to contact me.
Many thanks for your support.
Best regards,
Manuel
In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.
Hi,
The servos and steepers are powered from a protoboard through a power supply of 5V.
This is also powering the Arduino Uno to the 5V pin and GND pin.
Servos and stepper connect through a pin to digital Arduino Pins (4, 9, 10, 11). There is another card for controlling the movement of the Stepper.
It is very strange that we can not supply power from the Protoboard Power supply, and we need to do it through wires as you can see on the picture.
However, it does not work properly. In the case of the older card, it is possible to supply power through the Protoboard Power Supply.
The unique problem now is that the arm does not return to the initial position after doing the job. Although the motor Stepper motor starts in the code as you can see with:
motor.step(512);
And it ends with motor.step(-512), but it does not return to the initial position.