0

Motor shield v2 value setSpeed
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Motor shield v2 value setSpeed

by janofonsagrada on Sun Dec 10, 2017 2:23 pm

Hi
I try to pass a value generated by slide in the Android smartphone app to control the revolutions of the NEMA17. I get an error in String est and my question is if setSpeed ​​() does not accept more than the predefined revolutions in the code.
Thanks
Arduino UNO r3

Code: Select all | TOGGLE FULL SIZE
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_MS_PWMServoDriver.h"

Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 1);


String est = "";
String mode = "Manual";

void setup()
   {
     Serial.begin(9600); //Comunicación bluetooth
    AFMS.begin();
    Serial.println("Pulsa los modos para comenzar");
     
    }

void loop() {
  delayMicroseconds(1);

  if(Serial.available() > 0){
    est = Serial.readString(); // Reads the data from the serial port
 }


if (mode == 'auto') {
     for (int i = 0; i<=5; i++)
    {
   
   myMotor->setSpeed(est);       // xx rpm
   
   myMotor->step(200, FORWARD, SINGLE);     //200 EQUIVALE A 360 GRADOS DE GIRO
     
   
    }

janofonsagrada
 
Posts: 1
Joined: Wed Mar 15, 2017 7:20 am

Re: Motor shield v2 value setSpeed

by adafruit_support_bill on Sun Dec 10, 2017 2:44 pm

You are passing a string variable to setSpeed(). SetSpeed() requires an integer variable.
https://learn.adafruit.com/adafruit-mot ... d-uint16-t

adafruit_support_bill
 
Posts: 67814
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.