View unanswered posts | View active topics It is currently Mon Dec 22, 2014 9:35 pm






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

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)?

Thanks.


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

Joined: Tue May 15, 2007 9:02 am
Posts: 406
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
Profile
Rookie

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:
Code:
for(byte port=S1;port<=S4;port++){
//lol
}


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

_________________
My creations: techlego.blogspot.com


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 1 guest


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.