Brazo robótico con tres servos, un motor PAP en la base y una pinza con motor DC, todo ello controlado por un joystick, un potenciómetro y un módulo de 4 botones.
Se utlizan 6 puertos y la salida para motor M1



Video control manual
Por la cantidad de actuadores que lleva, servos, motor PAP, joystick, potenciómetro, modulo de botones y pinza incluyo el código para quien pueda interesar.
#include "MeOrion.h"
#include <SoftwareSerial.h>
#include <AccelStepper.h>
#include <Arduino.h>
#include <SoftwareSerial.h>
#include <Wire.h>
AccelStepper stepper(AccelStepper::DRIVER, 10, 11); // 10-PUL,11-DIR
// corresponde al PORT_1
MeDCMotor pinza(M1); // Pinza DC
MeJoystick joystick(PORT_8);
MePotentiometer potenciometro(PORT_7);
Me4Button botones(PORT_6);
//MePort port(PORT_3);
Servo base;
Servo brazo;
Servo muneca;
int base_pin = mePort[4].s1;
int brazo_pin = mePort[4].s2;
int muneca_pin = mePort[3].s2;
//int muneca_pin = port.pin2();
int x = 0; int y = 0;
int pot;
int vel=-100;
int tpo_pinza =150;
int tpo_mandos = 50;
int pos_muneca=90;
int pos_brazo=90;
int pos_base=90;
int tecla_pulsada = KEY_NULL;
long joystick_y;
//===========================================================
void setup() {
Serial.begin(9600);
muneca.attach(muneca_pin);
brazo.attach(brazo_pin);
base.attach(base_pin);
stepper.setMaxSpeed(10000);
//stepper.setSpeed(5000);
stepper.setAcceleration(2500);
stepper.setCurrentPosition(0);
delay(1000);
}
//==================================
void loop() {
tecla_pulsada = botones.pressed();
if (tecla_pulsada !=KEY_NULL){
if (tecla_pulsada == KEY_1) { baja_brazo();}
if (tecla_pulsada == KEY_3) { sube_brazo();}
if (tecla_pulsada == KEY_2) { sube_base();}
if (tecla_pulsada == KEY_4) { baja_base();}
}
//----------------------------------------------------
pot=potenciometro.read();
if (pot<300) {sube_muneca();}
if (pot>700) {baja_muneca();}
//----------------------------------------------------
x = joystick.readX();
if (x <-100) { cierra_pinza();}
if (x >100) { abre_pinza();}
y = joystick.readY();
if (y <-100) { stepper.move(100); }
if (y >100) { stepper.move(-100);}
stepper.run();
//stepper.runToNewPosition(newval);
joystick_y = stepper.currentPosition();
}
//==================================
void sube_base(){
base.write(pos_base);
pos_base=pos_base+1;
if(pos_base>=180) pos_base=180;
delay(tpo_mandos);
}
void baja_base(){
base.write(pos_base);
pos_base=pos_base-1;
if(pos_base<=0) pos_base=0;
delay(tpo_mandos);
}
void sube_brazo(){
brazo.write(pos_brazo);
pos_brazo=pos_brazo+1;
if(pos_brazo>=180) pos_brazo=180;
delay(tpo_mandos);
}
void baja_brazo(){
brazo.write(pos_brazo);
pos_brazo=pos_brazo-1;
if(pos_brazo<=0) pos_brazo=0;
delay(tpo_mandos);
}
void baja_muneca(){
while (pot>700){
muneca.write(pos_muneca);
pos_muneca=pos_muneca+1;
pot=potenciometro.read();
if(pos_muneca>=180) {pos_muneca=180;break;}
delay(tpo_mandos);
}
}
void sube_muneca(){
while (pot<300){
muneca.write(pos_muneca);
pos_muneca=pos_muneca-1;
pot=potenciometro.read();
if(pos_muneca<=0) {pos_muneca=0;break;}
delay(tpo_mandos);
}
}
void abre_pinza(){
pinza.run(vel);
delay(tpo_pinza);
pinza.run(0);
}
void cierra_pinza(){
pinza.run(-vel);
delay(tpo_pinza);
pinza.run(0);
}
Video control secuencial






Brazo robótico con tres servos, un motor PAP en la base y una pinza con motor DC, todo ello controlado por un joystick, un potenciómetro y un módulo de 4 botones.
Se utlizan 6 puertos y la salida para motor M1



[Video control manual](https://youtu.be/S0M04cjq0kg "Youtube")
--
Por la cantidad de actuadores que lleva, servos, motor PAP, joystick, potenciómetro, modulo de botones y pinza incluyo el código para quien pueda interesar.
````
#include "MeOrion.h"
#include <SoftwareSerial.h>
#include <AccelStepper.h>
#include <Arduino.h>
#include <SoftwareSerial.h>
#include <Wire.h>
AccelStepper stepper(AccelStepper::DRIVER, 10, 11); // 10-PUL,11-DIR
// corresponde al PORT_1
MeDCMotor pinza(M1); // Pinza DC
MeJoystick joystick(PORT_8);
MePotentiometer potenciometro(PORT_7);
Me4Button botones(PORT_6);
//MePort port(PORT_3);
Servo base;
Servo brazo;
Servo muneca;
int base_pin = mePort[4].s1;
int brazo_pin = mePort[4].s2;
int muneca_pin = mePort[3].s2;
//int muneca_pin = port.pin2();
int x = 0; int y = 0;
int pot;
int vel=-100;
int tpo_pinza =150;
int tpo_mandos = 50;
int pos_muneca=90;
int pos_brazo=90;
int pos_base=90;
int tecla_pulsada = KEY_NULL;
long joystick_y;
//===========================================================
void setup() {
Serial.begin(9600);
muneca.attach(muneca_pin);
brazo.attach(brazo_pin);
base.attach(base_pin);
stepper.setMaxSpeed(10000);
//stepper.setSpeed(5000);
stepper.setAcceleration(2500);
stepper.setCurrentPosition(0);
delay(1000);
}
//==================================
void loop() {
tecla_pulsada = botones.pressed();
if (tecla_pulsada !=KEY_NULL){
if (tecla_pulsada == KEY_1) { baja_brazo();}
if (tecla_pulsada == KEY_3) { sube_brazo();}
if (tecla_pulsada == KEY_2) { sube_base();}
if (tecla_pulsada == KEY_4) { baja_base();}
}
//----------------------------------------------------
pot=potenciometro.read();
if (pot<300) {sube_muneca();}
if (pot>700) {baja_muneca();}
//----------------------------------------------------
x = joystick.readX();
if (x <-100) { cierra_pinza();}
if (x >100) { abre_pinza();}
y = joystick.readY();
if (y <-100) { stepper.move(100); }
if (y >100) { stepper.move(-100);}
stepper.run();
//stepper.runToNewPosition(newval);
joystick_y = stepper.currentPosition();
}
//==================================
void sube_base(){
base.write(pos_base);
pos_base=pos_base+1;
if(pos_base>=180) pos_base=180;
delay(tpo_mandos);
}
void baja_base(){
base.write(pos_base);
pos_base=pos_base-1;
if(pos_base<=0) pos_base=0;
delay(tpo_mandos);
}
void sube_brazo(){
brazo.write(pos_brazo);
pos_brazo=pos_brazo+1;
if(pos_brazo>=180) pos_brazo=180;
delay(tpo_mandos);
}
void baja_brazo(){
brazo.write(pos_brazo);
pos_brazo=pos_brazo-1;
if(pos_brazo<=0) pos_brazo=0;
delay(tpo_mandos);
}
void baja_muneca(){
while (pot>700){
muneca.write(pos_muneca);
pos_muneca=pos_muneca+1;
pot=potenciometro.read();
if(pos_muneca>=180) {pos_muneca=180;break;}
delay(tpo_mandos);
}
}
void sube_muneca(){
while (pot<300){
muneca.write(pos_muneca);
pos_muneca=pos_muneca-1;
pot=potenciometro.read();
if(pos_muneca<=0) {pos_muneca=0;break;}
delay(tpo_mandos);
}
}
void abre_pinza(){
pinza.run(vel);
delay(tpo_pinza);
pinza.run(0);
}
void cierra_pinza(){
pinza.run(-vel);
delay(tpo_pinza);
pinza.run(0);
}
````
-----
[Video control secuencial](https://vimeo.com/188260703 "Vimeo")
--






editado 24 Oct '16 a las 6:15 pm