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.

  • 799 views
  • 0 comments
  • 2 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

Otto DIY+ Arduino Bluetooth Robot Easy to 3D Print

Project tutorial by Team Otto builders

  • 48,546 views
  • 117 comments
  • 163 respects

3D Printed and Expandable Robot for Arduino

Project showcase by Matthew Hallberg

  • 2,923 views
  • 3 comments
  • 15 respects

3D Printed R2-D2 with an Arduino Core

Project showcase by Raul Antonio

  • 3,329 views
  • 1 comment
  • 5 respects

WiFi Robot

Project tutorial by Team Kartik

  • 2,285 views
  • 1 comment
  • 8 respects

Tertiarm - 3d Printed Robot Arm

Project tutorial by Karagad

  • 8,100 views
  • 2 comments
  • 18 respects

Littlearm 2C: Build a 3D Printed Arduino Robot Arm

Project tutorial by Slant Concepts

  • 4,469 views
  • 1 comment
  • 33 respects
Add projectSign up / Login