View unanswered posts | View active topics It is currently Fri Sep 25, 2020 11:33 pm

Reply to topic  [ 3 posts ] 
Motor Arrays? 
Author Message

Joined: Wed Oct 20, 2010 3:24 pm
Posts: 3
Post Motor Arrays?
I'm trying to write a code that calibrates all of my four motors. I've written the code for just one motor, and instead of doing a copy/paste job, I want to run that original code through a FOR loop for each motor. So, is there such thing as an array of motors? Something like

motor mymotor[motor1, motor2, motor3, motor4] ?

So that way I can just replace "motor1" everywhere in the original code for mymotor[i] (if i is the indexing variable for the FOR loop)?


Wed Oct 20, 2010 3:31 pm
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 409
Post Re: Motor Arrays?
Copying and pasting is probably your safest bet. The motor command is already a one-dimensional array, so adding multiple array indexes separated by commas will cause a compiler error.

Jesse Flot
CMU Robotics Academy
ROBOTC Support

Wed Oct 20, 2010 5:17 pm

Joined: Tue Sep 07, 2010 10:56 am
Posts: 43
Post Re: Motor Arrays?
I don't know, but with the Sensors, you can do this:
for(byte port=S1;port<=S4;port++){

I don't know if it works with motors... try to do it =]

My creations:

Wed Oct 20, 2010 7:17 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.