View unanswered posts | View active topics It is currently Wed Dec 13, 2017 3:09 am






Reply to topic  [ 2 posts ] 
Creating a move multiple motors function 
Author Message
Rookie

Joined: Sat Apr 23, 2016 10:46 am
Posts: 1
Post Creating a move multiple motors function
I am trying to create a function to move 2 motors with one function. Here is what I have currently:

Code:
void movemotors(string fport1,string fport2, int speed, int time){
   motor[fport1] = speed;
   motor[fport2] = speed;
   wait1Msec(time*1000);
}


the string fport 1 and 2 are strings to input the ports you want to move. Speed is speed, and time is time. When I run this, I get the error:
**Error**:'&' Invalid parameter for reference variable. Call to 'movemotors'. Parameter: 'unsigned string & fport1' is 'port1' of type 'tMotor'.
Is there a way to make this work properly so I can write with it?


Sat Apr 23, 2016 10:55 am
Profile
Expert

Joined: Thu Dec 01, 2011 12:07 am
Posts: 151
Post Re: Creating a move multiple motors function
What you are trying to do is indirectly address the motors. The motor command would select the motor in the complier with the alphanumeric name. You want it to use the alphanumeric after the program has compiled.

You may need a function for each pair of motors you want to run.


Thu Apr 28, 2016 9:36 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.