Project tutorial
SMARS: 3D-Printed Arduino Caterpillar Robot

SMARS: 3D-Printed Arduino Caterpillar Robot © GPL3+

This is the basic model of the SMARS robot taken from the Thingiverse.

  • 2,045 views
  • 0 comments
  • 4 respects

Components and supplies

A000066 iso both
Arduino UNO & Genuino UNO
×1
Arduino motor shield
×1
DC motor (generic)
×2
61pby065esl  sx679  tnr8syww5d
HC-05 Bluetooth Module
×1

Necessary tools and machines

3drag
3D Printer (generic)
09507 01
Soldering iron (generic)

Apps and online services

About this project

Code

codeArduino
//This program is used to control a robot car using a app that communicates with Arduino through a bluetooth module

#include <AFMotor.h>

//creates two objects to control the terminal 3 and 4 of motor shield
AF_DCMotor motor1(3);
AF_DCMotor motor2(4);

char command;

void setup()
{
  Serial.begin(9600);  //Set the baud rate to your Bluetooth module.
}

void loop() {
  if (Serial.available() > 0) {
    command = Serial.read();
    Stop(); //initialize with motors stoped
    //Change pin mode only if new command is different from previous.
    //Serial.println(command);
    switch (command) {
      case 'F':
        forward();
        break;
      case 'B':
        back();
        break;
      case 'L':
        left();
        break;
      case 'R':
        right();
        break;
      case 'G':
        forwardleft();
        break;
      case 'I':
        forwardright();
        break;
      case 'H':
        backleft();
        break;
      case 'J':
        backright();
        break;
      
    }
  }
}

void forward()
{
  motor1.setSpeed(255); //Define maximum velocity
  motor1.run(FORWARD); //rotate the motor clockwise
  motor2.setSpeed(255); //Define maximum velocity
  motor2.run(FORWARD); //rotate the motor clockwise
}

void back()
{
  motor1.setSpeed(255);
  motor1.run(BACKWARD); //rotate the motor counterclockwise
  motor2.setSpeed(255);
  motor2.run(BACKWARD); //rotate the motor counterclockwise
}

void left()
{
  motor1.setSpeed(0); 
  motor1.run(RELEASE); //turn motor2 off
  motor2.setSpeed(255); //Define maximum velocity
  motor2.run(FORWARD); //rotate the motor clockwise
}

void right()
{
  motor1.setSpeed(255); //Define maximum velocity
  motor1.run(FORWARD); //rotate the motor clockwise
  motor2.setSpeed(0); 
  motor2.run(RELEASE); //turn motor1 off 
}

void Stop()
{
  motor1.setSpeed(0);
  motor1.run(RELEASE); //turn motor1 off
  motor2.setSpeed(0);
  motor2.run(RELEASE); //turn motor2 off
}
void forwardleft()
{
  motor1.setSpeed(100);
  motor1.run(FORWARD); //Rotate the motor at nearly medium speed
  motor2.setSpeed(255);
  motor2.run(FORWARD); //Rotate the motor at full speed
}
void forwardright()
{
  motor1.setSpeed(255);
  motor1.run(FORWARD); //Rotate the motor at full speed
  motor2.setSpeed(100);
  motor2.run(FORWARD); //Rotate the motor at nearly medium speed
}
void backleft()
{
  motor1.setSpeed(60);
  motor1.run(BACKWARD); //Rotate the motor at nearly medium speed
  motor2.setSpeed(255);
  motor2.run(BACKWARD); //Rotate the motor at full 
 
}
void backright()
{
  motor1.setSpeed(255);
  motor1.run(BACKWARD); //Rotate the motor at full speed
  motor2.setSpeed(60);
  motor2.run(BACKWARD); //Rotate the motor at nearly medium speed
}

Schematics

schematic

Comments

Similar projects you might like

4-Wheel Robot Made With Arduino Controlled Using Dabble

Project tutorial by STEMpedia

  • 9,083 views
  • 8 comments
  • 27 respects

Buddy, the 3D-Printed Arduino Social Robot

Project showcase by Slant Concepts

  • 8,651 views
  • 7 comments
  • 71 respects

Tito - Arduino UNO 3D-printed robot

Project tutorial by Camilo Parra Palacio

  • 18,784 views
  • 20 comments
  • 52 respects

Otto DIY+ Arduino Bluetooth robot easy to 3D Print

Project tutorial by Team Otto builders

  • 77,647 views
  • 136 comments
  • 219 respects

Amazing 6WD Off-Road Robot | Arduino RC Robot

Project tutorial by Jithin Sanal

  • 10,000 views
  • 0 comments
  • 54 respects

Rep_AL 3D-Printed Robot Lawn Mower

Project tutorial by ReP_AL

  • 7,660 views
  • 0 comments
  • 41 respects
Add projectSign up / Login