Hello,
So My idea is to have a limit switch mounted on a 3d printer. Once the printer goes to the home position after its done the robot will then move and pick the part up off of the printer. I have the limit switch code down I believe. From this point how do I code to have the robot make the appropriate moves to pick the part up. See the code below.
#include "xArmServoController.h"
xArmServoController xarm1 = xArmServoController(Serial1);
#define XarmServo
#define setPosition
int Lswitch = 2;
int led = 13;
int flag = 0;
#define setPostion
void setup()
{
Serial.begin(9600);
pinMode(Lswitch, INPUT);
pinMode(led, OUTPUT);
}
void loop()
{
if( (digitalRead(Lswitch) == LOW) && (flag == 0) )
{
Serial.println("3D Printer is in Home Position ");
flag = 1;
delay(20);
}
if( (digitalRead(Lswitch) == HIGH) && (flag == 1) )
{
Serial.println("3D Printer is in operation");
flag = 0;
delay(20);
if ( flag == 1 )
{
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
delay(1000);
`
}
if ( flag == 1 )
{
digitalWrite(led, LOW);
}
digitalWrite(Lswitch, HIGH);
}