1
resposta

Library VarSpeedServo não funciona

Sempre que eu coloco a library do VarSpeedServo ele me da o seguinte erro:

https://gist.github.com/MrSpuriz/a161931920c0ca68a65a733ff4d9c304

segue o codigo:

#include <VarSpeedServo.h>

#include <Servo.h>
#define inicial 90

#define joystick1X A0
#define joystick1Y A1
#define joystick2X A2
#define joystick2Y A3

VarSpeedServo motorBase;
VarSpeedServo motorBraco1;
VarSpeedServo motorBraco2;
VarSpeedServo motorGarra;  
int auxBase = inicial;
int auxBraco1 = inicial;
int auxBraco2 = inicial;
int auxGarra = inicial;


void setup() {
  mapaPinos();
  angulosiniciais();
  pinosjoysticks();

}

void loop() {
  base();
  braco1();
  braco2();
  garra();
  delay(100);
}

void mapaPinos() {
    motorBase.attach(5);
    motorBraco1.attach(6);
    motorBraco2.attach(9);
    motorGarra.attach(10);

}

void angulosiniciais(){
    motorBase.write(inicial);
    motorBraco1.write(inicial);
    motorBraco2.write(inicial);
    motorGarra.write(inicial);
}

void pinosjoysticks() {
  pinMode (joystick1X, INPUT);
  pinMode (joystick1Y, INPUT);
  pinMode (joystick2X, INPUT);
  pinMode (joystick2Y, INPUT);
}

void base() {
  int pos1X = analogRead(joystick1X);
  pos1X = map(pos1X, 0, 1023, 0, 180);
  if(pos1X > 100) {
    auxBase+=10;
  }else if(pos1X <80){
    auxBase-=10;
    motorBase.write(auxBase,50);
  }
}

void braco1() {
  int pos2Y = analogRead(joystick2Y);
  pos2Y = map(pos2Y, 0, 1023, 0, 160);
    if(pos2Y > 100) {
    auxBraco1+=10;
  }else if(pos2Y <80){
    auxBraco1-=10;
    motorBraco1.write(auxBraco1,50);
  }
}

void braco2() {
  int pos1Y = analogRead(joystick1Y);
  pos1Y = map(pos1Y, 0, 1023, 20, 180);
    if(pos1Y > 100) {
    auxBraco2+=10;
  }else if(pos1Y <80){
    auxBraco2-=10;
    motorBraco2.write(auxBraco2,50);
  }
}
void garra() {
  int pos2X = analogRead(joystick2X);
  pos2X = map(pos2X, 0, 1023, 90, 140);
    if(pos2X > 100) {
    auxGarra+=10;
  }else if(pos2X <80){
    auxGarra-=10;
    motorGarra.write(auxGarra,50);
  }
}
1 resposta

Fala ai Renan, de boa ?

Cara será que você já conseguiu solucionar isso ? Se sim, compartilha conosco sua solução

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software