You are on page 1of 4

Robot Table Information

Table Revolutions Time

Table 1 200 * 4 400 steps

Table 2 200 * 7 1400 steps

Table 3 200 * 7 1400 steps

Table 4 200 * 7 1400 steps

Table 5 200 * 7 1400 steps

Table 6 200 * 7 1400 steps

Robot Movement
The robot will move forward if there are no obstacles in its path. If it encounters an obstacle,
it will stop and wait for instructions.

Robot Speed
The robot's speed is set to 150 steps per minute.

Code
The following code is used to control the robot:

// Define the number of steps per revolution


const int stepsPerRevolution = 200;

// Define the table numbers


const int Table1 = 200 * 4;
const int Table2 = 200 * 7;
const int Table3 = 200 * 7;
const int Table4 = 200 * 7;
const int Table5 = 200 * 7;
const int Table6 = 200 * 7;

// Declare the stepper motors


Stepper myStepper1(200, 2, 3, 4, 5);
Stepper myStepper2(200, 8, 9, 10, 11);
Stepper myStepper3(200, 23, 25, 27, 29);
Stepper myStepper4(200, 31, 33, 35, 37);

// Define the obstacle detection function


void ObstacleDetect() {
// Measure the distance to the obstacle
float dist1 = distanceSensor1.measureDistanceCm();
float dist2 = distanceSensor2.measureDistanceCm();
float dist3 = distanceSensor3.measureDistanceCm();
float dist4 = distanceSensor4.measureDistanceCm();

// If any of the distances are less than 50 cm, stop the robot
if (dist1 < 50 || dist2 < 50 || dist3 < 50 || dist4 < 50) {
myStepper1.step(0);
myStepper2.step(0);
myStepper3.step(0);
myStepper4.step(0);
}
}

// Define the load detection function


void LoadDetect() {
// Read the load cell value
float load = LoadCell.getData();

// If the load is greater than 1000 grams, stop the robot


if (load >= 1000) {
myStepper1.step(0);
myStepper2.step(0);
myStepper3.step(0);
myStepper4.step(0);
}
}

// Define the table movement functions


void table1() {
// Move the robot to table 1
for (int i = 0; i <= Table1; i++) {
ObstacleDetect();
LoadDetect();

// Step the motors forward


myStepper1.step(1);
myStepper2.step(1);
myStepper3.step(1);
myStepper4.step(1);
}
}

void table2() {
// Move the robot to table 2
for (int i = 0; i <= Table2; i++) {
ObstacleDetect();
LoadDetect();

// Step the motors forward


myStepper1.step(1);
myStepper2.step(1);
myStepper3.step(1);
myStepper4.step(1);
}
}

// ... and so on for the other tables

Example Usage
To send the robot to table 1, you would send the following command:

To send the robot to table 2, you would send the following command:
2

... and so on for the other tables.

You might also like