|
Page 1 of 1
|
[ 4 posts ] |
|
Refer to motor in function
| Author |
Message |
|
sqiddster
Rookie
Joined: Mon Jun 11, 2012 9:28 pm Posts: 36
|
 Refer to motor in function
Hello everyone,
I am somewhat of a beginner so sorry if this is a simple question... I name all my motors, it seems like the best practice. I have a function which controls a motor, and I want to be able to choose which motor the function applies to when I call it. If I use a string variable in the function declaration and put this in the motor command, I get lots of array errors. So, how do I do this?
Many thanks, sqiddster
|
| Mon Jun 11, 2012 9:31 pm |
|
 |
|
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 509 Location: Totally not spying on Hassenplug to see what he has for the Brickworld Chicago 2013 sumo contest.
|
 Re: Refer to motor in function
Could you please post your code? Put it in the tags.
_________________A.K.A. inxt-generation Self-proclaimed genius, and future world dominator. My Brickshelf Folder"Don't they teach recreational mathematics anymore?" - The Tenth Doctor Bow down to Nikola Tesla, King of the Geek Gods.
|
| Mon Jun 11, 2012 9:35 pm |
|
 |
|
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1023
|
 Re: Refer to motor in function
Do you mean something like this?  |  |  |  | Code: #pragma config(Motor, motorA, rightMotor, tmotorNormal, openLoop, encoder) #pragma config(Motor, motorC, leftMotor, tmotorNormal, openLoop, encoder)
void SetMotorPower(tMotor motorID, int power) { motor[motorID] = power; }
|  |  |  |  |
|
| Mon Jun 11, 2012 9:53 pm |
|
 |
|
sqiddster
Rookie
Joined: Mon Jun 11, 2012 9:28 pm Posts: 36
|
 Re: Refer to motor in function
 |  |  |  | MHTS wrote: Do you mean something like this?  |  |  |  | Code: #pragma config(Motor, motorA, rightMotor, tmotorNormal, openLoop, encoder) #pragma config(Motor, motorC, leftMotor, tmotorNormal, openLoop, encoder)
void SetMotorPower(tMotor motorID, int power) { motor[motorID] = power; }
|  |  |  |  |
|  |  |  |  |
I think that's it! So there's a variable type called tMotor... OK, cool. I was using a string. Thanks!
|
| Tue Jun 12, 2012 6:11 am |
|
|
|
Page 1 of 1
|
[ 4 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 4 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
|
|