Zyad Reda
Published

Robot Arm

Control robot arm by phone (orientation).

IntermediateWork in progress1 hour616
Robot Arm

Things used in this project

Story

Read more

Schematics

fritzing

Code

Orientation

C/C++
#include  <Servo.h>
#include <OneSheeld.h>
Servo myservo1;
Servo myservo2;
Servo myservo3;
void setup() 
{ 
  OneSheeld.begin();
  myservo1.attach(3);
  myservo1.write(0);
  myservo2.attach(10);
  myservo2.write(70);
  myservo3.attach(11);
  myservo3.write(10);
  analogWrite(6, 200);
  analogWrite(9, 200);
} 
void loop() {
  if (ProximitySensor.getValue() > 0)
    myservo3.write(10);
  else 
    myservo3.write(120);
  if(OrientationSensor.getX() > 0 && OrientationSensor.getX() <= 180)
    myservo1.write(map(abs(OrientationSensor.getX()),0,180,180,0));   
  if(OrientationSensor.getZ() > 0 &&  abs(OrientationSensor.getZ()) <= 60)
    myservo2.write(map(OrientationSensor.getZ(),0,60,70,180));   
  if(OrientationSensor.getZ() < 0 &&  abs(OrientationSensor.getZ()) <= 60)
    myservo2.write(map(abs(OrientationSensor.getZ()),0,60,70,0));
  OneSheeld.processInput();
}

Credits

Zyad Reda

Zyad Reda

2 projects • 2 followers

Comments