Main Project: Robot 2021-2022

This is my main project that I built, designed and programmed over the year. This specific robot doesn’t have a particular purpose. I mainly built it to serve different purposes a few things this robot can do is, lifting close to 100 grams using it’s robotic hand. It can also drag almost half a kilogram. One thing I am very proud I added was a solar panel it allows a robot to charge using sunlight. The robot is equipped with a 1500mah battery that provides enough power to run the robot for more then 10 hours without charging. In combination with a solar panel on a sunny day the robot can work up to 16 hours. The processor used to guide the robot is Arduino Mega 2560. In total the robot has two 5v dc motors and two 360 degree servos. For the hand motion I had to use a motor controller to better guide the movements of the hand. Top speed is about 3-5km/h. The speed could be increased, although these specific motors are used for better torque. The robot can be used to do repetitive or boring work, although different programs allow for a range of different tasks like remote control (using IR transmitter and receiver). Autonomous program allows you to give the robot a task and watch it complete the task without interference form the person. Also after building Automated Chopsticks I learned what i could do to improve the hand of the robot to be more accurate.

This is version 3 of this robot.

Program for version 3 robot (IR controlled) :

// All comands for Lm.2

// controller type (ELEGOO IR TRANSMITTER)

// turn right 50 degrees -----> RIGHT ARROW
// turn left 50 degrees ------> LEFT ARROW

// forward 0.6s -------> PAUSE/PLAY
// forward 3s -------> 3

// spin in a circle 3s ------> ST/REPT

// arm up ------> 2
// arm down -----> 5
// arm middle -----> 9
// hand open -----> 0
// hand close -----> 1

// stop all motors ----> RED BUTTON

// When the motors are off the breaks engage. To change this function look for (function3) in the code.

#include <IRremote.h>
int IRpin = 10; 
IRrecv irrecv(IRpin);
decode_results results;
int pos = 70;
#include <Servo.h>
Servo myservo;

void setup() {
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(2, OUTPUT); //hand close
pinMode(3, OUTPUT); // hand open
Serial.begin(9600);
myservo.attach(4); 
}

void loop() {
if (irrecv.decode(&results)) 
{
irrecv.resume(); 
}
if (irrecv.decode(&results)) 
{
irrecv.resume(); 
}
if (irrecv.decode(&results)) 
{
irrecv.resume(); 
}
if (results.value == 16718055)
{
for (pos = 45; pos <= 150; pos += 1) { 
// in steps of 1 degree
myservo.write(pos); 
delay(10); 
}
}
if (results.value == 16726215) 
{ 
for (pos = 150; pos >= 45; pos -= 1) { 
myservo.write(pos); 
delay(10); 
}
}
if (results.value == 16720605) 
{
digitalWrite(8, HIGH);
delay(250); // left 250ms
digitalWrite(8, LOW);
}
if (results.value == 16761405) 
{
digitalWrite(9, HIGH);
delay(250); // right 250ms
digitalWrite(9, LOW);
}
if (results.value == 16712445) 
{
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
delay(600); // forward 600ms
digitalWrite(8, LOW);
digitalWrite(9, LOW);
}
if (results.value == 16753245) 
{
digitalWrite(8, LOW);
digitalWrite(9, LOW); // stop all motors / release hand 
digitalWrite(2, LOW);
delay(400);
}
if (results.value == 16743045) 
{
digitalWrite(8, HIGH);
digitalWrite(9, HIGH); // forward 3 seconds
delay(3000);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
}
if (results.value == 16756815) 
{
digitalWrite(8, LOW);
digitalWrite(9, HIGH); // spin in a circle 3 seconds
delay(3000);
}
if (results.value == 16738455) 
{
digitalWrite(3, HIGH);
delay(50);
digitalWrite(3, LOW); // hand open
delay(150);
} 
if (results.value == 16724175) 
{
digitalWrite(2, HIGH);
// hand close
} 
if (results.value == 16728765)
{
for (pos = 45; pos <= 70; pos += 1) { // half point arm
// in steps of 1 degree
myservo.write(pos); 
delay(10); 
}
}
if (results.value == 16728765)
{
for (pos = 150; pos >= 70; pos -= 1) { // half point arm
// in steps of 1 degree
myservo.write(pos); 
delay(10); 
  }
 }
}

Program for version 3 robot (Autonomous) :

int inputPin = 2; // choose the input pin (for PIR sensor)
int pirState = LOW; // start, assuming no motion detected
int val = 0; // variable for reading the pin status

#define right 9
#define left 8

long randNumber;

void setup() {

Serial.begin(9600); 
randomSeed(analogRead(0)); // unconnected pin
}

void loop() {

randNumber = random(3); // generate a number 1 or 2 in a random order
Serial.println(randNumber);

delay(50);

if (randNumber < 1) {
digitalWrite(left, HIGH);
delay(500);
digitalWrite(left, LOW);
delay(500);
}
if ( randNumber > 1) {
digitalWrite(right, HIGH);
delay(500);
digitalWrite(right, LOW);
delay(500);
   }
}

This code is used to map the environment the robot is in, ones the data has been acquired directions can be added. Allowing the robot to do various tasks.

Leave a Reply

Your email address will not be published. Required fields are marked *