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
    About the element14 Community
  • 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
STEM Projects
  • Learn
  • Learning Center
  • STEM Academy
  • STEM Projects
  • More
  • Cancel
STEM Projects
Blog Moving forward  with the project (And turning)
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join STEM Projects to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: adnathanail
  • Date Created: 13 Sep 2015 10:05 PM Date Created
  • Views 551 views
  • Likes 1 like
  • Comments 1 comment
  • teachers_pet
  • r4gv
  • teachers pet robotics design challenge
  • r4gv_project
Related
Recommended

Moving forward  with the project (And turning)

adnathanail
adnathanail
13 Sep 2015

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

 

This video showed the turning and moving in action and below I'll explain the code.

image

 

This code is to test the turning function.

Line 1 clears the workspace.

Line 2 defines "a" as the connected arduino.

Lines 3 and 4 define "sRight" and "sLeft" as the two servos connected to pins 11 and 12.

Line 5 runs the turn function passing it the two servos and the speed and angle.

image

Line 1 defines the function called turn which takes 2 servos as inputs and the speed, between 0 and 1, and the angle you want it to turn to in degrees.

Lines 2 and 3 defines "leftSpeed" and "rightSpeed" as the speeds which the two servos need to go at to move forwards in accordance with the speed.

Line 4 defines "zeroSpeed" as the speed which both of the servos need to go at to be still.

Line 5 start a parallel for loop which will loop twice.

Lines 6-10 a set of if statements which say that on one run of the loop one servo will start on the next loop the other will start and as its a parfor in theory they should both happen at the same time.

Line 11 ending the parfor.

Line 12 waits for the right amount of time to make it turn to the inputted angle.

Lines 13 and 14 turn off the servos.

Line 15 end the function.

image

This code is to test the moving function.

Line 1 clears the workspace.

Line 2 defines "a" as the connected arduino.

Lines 3 and 4 define "sRight" and "sLeft" as the two servos connected to pins 11 and 12.

Line 5 runs the move function passing it the two servos and the speed and angle.

image

Line 1 defines the function called move which takes 2 servos as inputs and the speed, between 0 and 1, and the distance you want it to go to in cm.

Lines 2 and 3 defines "leftSpeed" and "rightSpeed" as the speeds which the two servos need to go at to move forwards in accordance with the speed.

Line 4 defines "zeroSpeed" as the speed which both of the servos need to go at to be still.

Line 5 start a parallel for loop which will loop twice.

Lines 6-10 a set of if statements which say that on one run of the loop one servo will start on the next loop the other will start and as its a parfor in theory they should both happen at the same time.

Line 11 ending the parfor.

Line 12 waits for the right amount of time to make it move to the inputted distance.

Lines 13 and 14 turn off the servos.

Line 15 end the function.

 

Apologies for the monotony of that.

One final post coming soon...

Alexander

Attachments:
move.m.zip
turn.m.zip
servoOutputs.m.zip
  • Sign in to reply
  • madhugovindarajan
    madhugovindarajan over 10 years ago

    Nice job on the write up with pictures included whenever necessary image

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