View unanswered posts | View active topics It is currently Thu Apr 19, 2018 5:21 pm

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Refer to motor in function
Author Message
Rookie

Joined: Mon Jun 11, 2012 9:28 pm
Posts: 37
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
Senior Roboticist

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Re: Refer to motor in function
 Code:[code][/code]
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
Guru

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
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
Rookie

Joined: Mon Jun 11, 2012 9:28 pm
Posts: 37
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
Display posts from previous:  Sort by
 Page 1 of 1 [ 4 posts ]

#### Who is online

Users browsing this forum: No registered users and 2 guests

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

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning