element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs Project Revive Robot #1
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: skywalker1211
  • Date Created: 31 Oct 2019 3:51 PM Date Created
  • Views 1022 views
  • Likes 9 likes
  • Comments 2 comments
  • esp32
  • ble
  • arduino uno
  • robot
  • robot project
  • remote controlled
  • ps3_controller
  • arduino
Related
Recommended

Project Revive Robot #1

skywalker1211
skywalker1211
31 Oct 2019

visited my friend's lab few days back. found a lot robot bodies in junk.

it has been sometime since i last build a robot. i think it is a good time for me to pick it up again, since there are ready made robot bodies for me to work on.

found a robot structure in good condition. but almost everything is dismantled from the robot.

Missing screws, nuts, connectors. These are minor problems, I can get it easily from hardware shop.

 

going to make it as RC robot. RC robot is a good start point.

program is not as complicated as automatic robot. circuitry is relatively simple. one remote control, a 2-channel motor driver. no sensor at all.

list of components:

structure x 1

motor x 4, in fact only 2 are needed. i am using 4 here because it is designed in this way.+_+

wheels x 4.

WiFi UNO based ESP32 board x 1

Monster Motor Shield VNH2SP30 x 1

battery x 1

ps3 remote control x 1

some screws and standoffs.

 

this is also the reason i starting my last blog post,Interfacing PS3 with ESP32

i wanted to use ps3 as remote control, and the robot has no space for USB host shield.

 

image

 

time lapse video of robot assembly process

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

 

uploading program to arduino

image

 

Yay!, the robot is moving.

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

source code

#include <Ps3Controller.h>
#include <BLEDevice.h>


#define LED_PWM_CHANNEL0 0
#define LED_PWM_CHANNEL1 1
#define FREQUENCY 5000
#define RESOLUTION 8


#define BRAKE 0
#define CW    1
#define CCW   2


//MOTOR 1
#define MOTOR_CW1_PIN 14
#define MOTOR_CCW1_PIN 12


//MOTOR 2
#define MOTOR_CW2_PIN 17
#define MOTOR_CCW2_PIN 13


#define PWM_MOTOR_1 16
#define PWM_MOTOR_2 27


#define EN_PIN_1 2
#define EN_PIN_2 4


#define MOTOR_1 0
#define MOTOR_2 1


void setup()
{
  // setup motor driver
  pinMode(MOTOR_CW1_PIN, OUTPUT);
  pinMode(MOTOR_CCW1_PIN, OUTPUT);
  
  pinMode(MOTOR_CW2_PIN, OUTPUT);
  pinMode(MOTOR_CCW2_PIN, OUTPUT);
  
  pinMode(PWM_MOTOR_1, OUTPUT);
  pinMode(PWM_MOTOR_2, OUTPUT); 
  
  pinMode(EN_PIN_1, OUTPUT);
  pinMode(EN_PIN_2, OUTPUT);


  ledcSetup(LED_PWM_CHANNEL0, FREQUENCY, RESOLUTION);
  ledcSetup(LED_PWM_CHANNEL1, FREQUENCY, RESOLUTION);
  ledcAttachPin(PWM_MOTOR_1, LED_PWM_CHANNEL0);
  ledcAttachPin(PWM_MOTOR_2, LED_PWM_CHANNEL1);


  // setup ps3
  Serial.begin(115200);
  Ps3.begin("11:22:33:44:55:66");
  Serial.println("Ready.");
  BLEDevice::setPower(ESP_PWR_LVL_P9);
}


void loop()
{
  if (Ps3.isConnected()){
    digitalWrite(EN_PIN_1, HIGH);
    digitalWrite(EN_PIN_2, HIGH);
    if( Ps3.data.button.cross ){
      Serial.println("Backward");
      Reverse();
    }   
    else if( Ps3.data.button.square ){
      Serial.println("Left");
      Left();
    }
    else if( Ps3.data.button.triangle ){
      Serial.println("Forward");
      Forward();
    }
    else if( Ps3.data.button.circle ){
      Serial.println("Right");
      Right();
    }
    else
      Stop();
  }
}


void Stop()
{
  motorGo(MOTOR_1, BRAKE, 0);
  motorGo(MOTOR_2, BRAKE, 0);
}


void Forward()
{
  motorGo(MOTOR_1, CW, 128);
  motorGo(MOTOR_2, CW, 128);
}


void Reverse()
{
  motorGo(MOTOR_1, CCW, 128);
  motorGo(MOTOR_2, CCW, 128);
}


void Left()
{
  motorGo(MOTOR_1, CCW, 128);
  motorGo(MOTOR_2, CW, 128);
}


void Right()
{
  motorGo(MOTOR_1, CW, 128);
  motorGo(MOTOR_2, CCW, 128);
}


void motorGo(uint8_t motor, uint8_t dir, uint8_t pwm)         //Function that controls the variables: motor(0 ou 1), direction (cw ou ccw) e pwm (entra 0 e 255);
{
  if(motor == MOTOR_1)
  {
    if(dir == CW)
    {
      digitalWrite(MOTOR_CW1_PIN, LOW); 
      digitalWrite(MOTOR_CCW1_PIN, HIGH);
    }
    else if(dir == CCW)
    {
      digitalWrite(MOTOR_CW1_PIN, HIGH);
      digitalWrite(MOTOR_CCW1_PIN, LOW);      
    }
    else
    {
      digitalWrite(MOTOR_CW1_PIN, LOW);
      digitalWrite(MOTOR_CCW1_PIN, LOW);            
    }
    ledcWrite(LED_PWM_CHANNEL0, pwm);
  }
  else if(motor == MOTOR_2)
  {
    if(dir == CW)
    {
      digitalWrite(MOTOR_CW2_PIN, LOW);
      digitalWrite(MOTOR_CCW2_PIN, HIGH);
    }
    else if(dir == CCW)
    {
      digitalWrite(MOTOR_CW2_PIN, HIGH);
      digitalWrite(MOTOR_CCW2_PIN, LOW);      
    }
    else
    {
      digitalWrite(MOTOR_CW2_PIN, LOW);
      digitalWrite(MOTOR_CCW2_PIN, LOW);            
    }
    ledcWrite(LED_PWM_CHANNEL1, pwm);
  }
}

 

will definitely visit my friend again, see what he has got in his lab!

  • Sign in to reply

Top Comments

  • DAB
    DAB over 6 years ago +4
    Nice project. It is always a good day when you can turn trash into something useful. DAB
  • dubbie
    dubbie over 6 years ago +2
    Great R/C tank thing. Should be easy to add some sensors to make it semi-autonomous. I wish I had friends who just have junk robots lying around that I can use. Dubbie
Parents
  • dubbie
    dubbie over 6 years ago

    Great R/C tank thing. Should be easy to add some sensors to make it semi-autonomous. I wish I had friends who just have junk robots lying around that I can use.

     

    Dubbie

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • dubbie
    dubbie over 6 years ago

    Great R/C tank thing. Should be easy to add some sensors to make it semi-autonomous. I wish I had friends who just have junk robots lying around that I can use.

     

    Dubbie

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube