Problem creating Robotic arm Web controlled with Arduino UNO Wifi Rev2

Hi, I'm new on Arduino projects and after long hours trying I´ve not been capable to accomplish the code work so would like some help, please.
The project is a 6 Servo motor based robotic arm to be controlled through a website.
I´ve based my project from https://create.arduino.cc/projecthub/phpoc_man/arduino-control-arm-robot-via-web-379ef3
This is the code that I'm using but it gives back a wrong compilation message: conversion from 'int' to 'arduino::String' is ambiguous

Could anyone help with that?
Thanks in advance!

#include <Servo.h>
#include <SPI.h>
#include <WiFiNINA.h>

char ssid[] = "";
char pass[] = "";

int angle_init[]  = {90, 101, 165, 153, 90, 120}; // when motor stands straight. In web, the angle when motor stands straight is {0, 90, 130, 180, 0, 0};
int angle_offset[]  = {0, 11, -15, -27, 0, 137}; // offset between real servo motor and angle on web
int cur_angles[]  = {90, 101, 165, 153, 90, 120}; // current angles of six motors (degree) 
int dest_angles[] = {0, 0, 0, 0, 0, 0}; // destined angles
int angle_max[]   = {180, 180, 160, 120, 180, 137};
int angle_min[]   = { 0, 0, 0, 20, 0, 75};
int direction[]   = {1, 1, 1, 1, 1 ,-1};
int angleSteps[]  = {3, 2, 2, 2, 4 ,4}; // moving steps of each motor (degree)

Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;
Servo servo6;

Servo servo[6] = {servo1, servo2, servo3, servo4, servo5, servo6};

int status = WL_IDLE_STATUS;
WiFiServer server(80);

int stepNum = 0;
  
void setup() {

//start serial communication
    Serial.begin(9600);

  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to Network named: ");
    Serial.println(ssid);
    status = WiFi.begin(ssid, pass);
    delay(10000);
 
    server.begin();

    Serial.print("SSID: ");
    Serial.println(WiFi.SSID());
    IPAddress ip = WiFi.localIP();
    Serial.print("IP Address: ");
    Serial.println(ip);

}
  servo1.attach(2);  // attaches the servo on pin 2 to the servo object
  servo2.attach(3);  // attaches the servo on pin 3 to the servo object
  servo3.attach(4);  // attaches the servo on pin 4 to the servo object
  servo4.attach(5);  // attaches the servo on pin 5 to the servo object
  servo5.attach(6);  // attaches the servo on pin 6 to the servo object
  servo6.attach(7);  // attaches the servo on pin 7 to the servo object

  for(int i = 0; i < 6; i++)
    servo[i].write(angle_init[i]);
}

void loop() {

  WiFiClient client = server.available(); // Listen for incoming clients

    if(client) {
    String angleStr = client.read();
  }

    if(angleStr) {
      Serial.println(angleStr);
      int commaPos1 = -1;
      int commaPos2;

      for(int i = 0; i < 5; i++) {
        commaPos2 = angleStr.indexOf(',', commaPos1 + 1);
        int angle = angleStr.substring(commaPos1 + 1, commaPos2).toInt();
        dest_angles[i] = angle * direction[i] + angle_offset[i];
        commaPos1 = commaPos2;
      }

      int angle5 = angleStr.substring(commaPos1 + 1).toInt();
      dest_angles[5] = angle5 * direction[5] + angle_offset[5];

      stepNum = 0;

      // move motors in many small steps to make motor move smooth, avoiding move motor suddently. The below is step calculation
      for(int i = 0; i < 6; i++) {
        int dif = abs(cur_angles[i] - dest_angles[i]);
        int step = dif / angleSteps[i];

        if(stepNum < step)
          stepNum = step;
      }
    }

  // move motors step by step
   if(stepNum > 0) {
    for(int i = 0; i < 6; i++) {
      int angleStepMove = (dest_angles[i] - cur_angles[i]) / stepNum;
      cur_angles[i] += angleStepMove;

      if(cur_angles[i] > angle_max[i])
        cur_angles[i] = angle_max[i];
      else if(cur_angles[i] < angle_min[i])
        cur_angles[i] = angle_min[i];

      servo[i].write(cur_angles[i]);
    }

    stepNum--;
    delay(20);
  }
}

That String goes out of scope pretty quick

It also told you where the error was, but you chose not to share that.

Sorry, the error is in

String angleStr = client.read();

Any solution?

Well, I almost never use String, but apart from the scope issue, how about

angleStr += (char) client.read();

Thanks for your help!
It gives back another issue: 'angleStr' was not declared in this scope
on

if(angleStr) {

Yes, that was the scope issue I mentioned earlier.

Since I'm brand new on Arduino, I do not know how to move on from this point.
Any suggestion or cue would be very welcome :slight_smile:

Sure - try here

Thanks so much!
It is not for beginners at all though. I'm thinking in trying to learn what it says or learn Chinese instead. Maybe second option consumes less time. :joy:
If anyone with knowledge could rewrite the code to work I thing it would help many people in the community. I'll do my best and if I find the solution I'll share it here.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.