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

580e3ad88b333.jpg

580e3b4184f10.jpg

580e3c0595856.jpg

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

580e3ea3b0d3a.jpg

580e3f28cdbc4.jpg

580e3f7242c27.jpg

580e400b14db8.jpg

580e40594d31d.jpg

580e40b809165.jpg

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 ![580e3ad88b333.jpg](serve/attachment&path=580e3ad88b333.jpg) ![580e3b4184f10.jpg](serve/attachment&path=580e3b4184f10.jpg) ![580e3c0595856.jpg](serve/attachment&path=580e3c0595856.jpg) [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") -- ![580e3ea3b0d3a.jpg](serve/attachment&path=580e3ea3b0d3a.jpg) ![580e3f28cdbc4.jpg](serve/attachment&path=580e3f28cdbc4.jpg) ![580e3f7242c27.jpg](serve/attachment&path=580e3f7242c27.jpg) ![580e400b14db8.jpg](serve/attachment&path=580e400b14db8.jpg) ![580e40594d31d.jpg](serve/attachment&path=580e40594d31d.jpg) ![580e40b809165.jpg](serve/attachment&path=580e40b809165.jpg)
editado 24 Oct '16 a las 6:15 pm
703
vistas
0
respuestas
1
seguidores
vista previa (en vivo)
introduzca al menos un 10 caracteres
Advertencia: Mencionaste a %MENTIONS%, pero ellos no pueden ver el mensaje y no serán notificados
Guardando...
Guardado
Todos los posteos de este tema serán borrados ?
Borrador pendiente ... Click para continuar editando
Descartar borrador