ROBOTC.net forums
http://robotc.net/forums/

Motor Arrays?
http://robotc.net/forums/viewtopic.php?f=11&t=2673
Page 1 of 1

Author:  crablab [ Wed Oct 20, 2010 3:31 pm ]
Post subject:  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.

Author:  jbflot [ Wed Oct 20, 2010 5:17 pm ]
Post subject:  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.

Author:  ivanseidel [ Wed Oct 20, 2010 7:17 pm ]
Post subject:  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

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/