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 Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • 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
Shift it! Warehouse Automation Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Shift it! Warehouse Automation Design Challenge
  • More
  • Cancel
Shift it! Warehouse Automation Design Challenge
Forum Test Drive of the Robot Base
  • News
  • Forum
  • Projects
  • Leaderboard
  • Files
  • Members
  • Mentions
  • More
  • Cancel
  • New
Join Shift it! Warehouse Automation Design Challenge to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 1 reply
  • Subscribers 40 subscribers
  • Views 108 views
  • Users 0 members are here
  • Shift it! Warehouse Automation Design Challenge
  • arduino
Related

Test Drive of the Robot Base

taifur
taifur 1 month ago

The motor, motor driver and Arduino connections are as follows:

image

For powering the motors a 3-cell Li-po battery is used. Below is the Arduino code for driving the motor in forward and backward direction.

#define LEFT_MOTOR_IN1 7
#define LEFT_MOTOR_IN2 8
#define RIGHT_MOTOR_IN1 4
#define RIGHT_MOTOR_IN2 5
#define LEFT_MOTOR_EN 9
#define RIGHT_MOTOR_EN 6


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
 
  pinMode(LEFT_MOTOR_IN1, OUTPUT);
  pinMode(LEFT_MOTOR_IN2, OUTPUT);
  pinMode(RIGHT_MOTOR_IN1, OUTPUT);
  pinMode(RIGHT_MOTOR_IN2, OUTPUT);
  pinMode(LEFT_MOTOR_EN, OUTPUT);
  pinMode(RIGHT_MOTOR_EN, OUTPUT);
  
}

void loop() {

  move_robot(100, 100); //move forward
  delay(5000);
  move_robot(100, -100); //turn right
  delay(1000);
  move_robot(100, 100); //move forward
  delay(5000);
  move_robot(-100, 100); //turn left
  delay(1000);
  move_robot(-100, -100); //move backword
  delay(5000);
}



void move_robot(int left_speed, int right_speed){
  int left_motor_speed = abs(left_speed);
  int right_motor_speed = abs(right_speed);
  analogWrite(LEFT_MOTOR_EN, left_motor_speed);
  analogWrite(RIGHT_MOTOR_EN, right_motor_speed);
  if(left_speed>=0){
    digitalWrite(LEFT_MOTOR_IN1, HIGH);
    digitalWrite(LEFT_MOTOR_IN2, LOW);
  }
  else if(left_speed<0){
    digitalWrite(LEFT_MOTOR_IN1, LOW);
    digitalWrite(LEFT_MOTOR_IN2, HIGH);
  }
  if(right_speed>=0){
    digitalWrite(RIGHT_MOTOR_IN1, HIGH);
    digitalWrite(RIGHT_MOTOR_IN2, LOW);
  }
  else if(right_speed<0){
    digitalWrite(RIGHT_MOTOR_IN1, LOW);
    digitalWrite(RIGHT_MOTOR_IN2, HIGH);
  }
}

A demo video:

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

  • Sign in to reply
  • Cancel
  • DAB
    DAB 1 month ago

    Looks agile.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
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