Hello everyone, I am realizing a robot arm 6 DOF with Arduino UNO and 1Sheeld to control it via orientation and proximity sensor to open / close the clamp. For the project I used 4 Servo MG996R Tower Pro, Pro 3 MG90S Tower and Tower Pro SG90.
The robot is mounted and ready for programming, and here come the problems. I am in possession of a partial program to Arduino, available on the web, in the sketch are registered only 4 Servo and I have 8 to use, but the problem is not here.
Once uploaded the sketch to Arduino, connected my iPhone to 1Sheeld + (checking that the "Serial Port" switch is in the correct position) and activating the necessary sensors in the application for smartphones, the arm does not want to move, following the movements my phone. I am attaching the sketch, hoping you can help me out ..
Thanks in advance, Federico
#include <Servo.h>
#include <OneSheeld.h>
Servo myservo1;
Servo myservo2;
Servo myservo5;
Servo myservo6;
void setup()
{
OneSheeld.begin();
myservo1.attach(3);
myservo1.write(0);
myservo2.attach(5);
myservo2.write(0);
myservo5.attach(10);
myservo5.write(70);
myservo6.attach(11);
myservo6.write(10);
analogWrite(6, 200);
analogWrite(9, 200);
}
void loop() {
if (ProximitySensor.getValue() > 0)
myservo6.write(10);
else
myservo6.write(120);
if(OrientationSensor.getX() > 0 && OrientationSensor.getX() <= 180)
myservo1.write(map(abs(OrientationSensor.getX()),0,180,180,0));
if(OrientationSensor.getY() < -90 && OrientationSensor.getY() >= -180)
myservo2.write(map(abs(OrientationSensor.getY()),180,90,0,90));
if(OrientationSensor.getZ() > 0 && abs(OrientationSensor.getZ()) <= 60)
myservo5.write(map(OrientationSensor.getZ(),0,60,70,180));
if(OrientationSensor.getZ() < 0 && abs(OrientationSensor.getZ()) <= 60)
myservo5.write(map(abs(OrientationSensor.getZ()),0,60,70,0));
OneSheeld.processInput();
}