View unanswered posts | View active topics It is currently Wed Jun 29, 2016 5:58 pm

 Page 1 of 1 [ 2 posts ]
 Print view Previous topic | Next topic
random; rand();
Author Message
Rookie

Joined: Mon Nov 17, 2008 11:32 pm
Posts: 5
random; rand();
i am writing a code and i need both motors to go in at a random speed between -100 and 100. i tried

motor[lm] = rand(-100 - 100)
motor[rm] = rand(-100 - 100)

and several other things. is there a way to wright so that it will work?

Sun Aug 23, 2009 4:22 pm
Expert

Joined: Tue Oct 14, 2008 7:16 pm
Posts: 171
Location: Investigating an unidentified ship sighted in Sector 31428
Re: random; rand();
Unfortunatly RobotC does not have a random number function, at least as of version 1.46; I can't speak for the latest version though. If there were it would look something like this,
 Code:rand(-100, 100);

Note the comma, as written your code would set the lower bound at -200, not specify bounds of -100 and 100.

P.S. There is no "ght" in write and when used as a pronoun "I" is capitalized. FYI

_________________
Captain, Head programmer, School of the Arts, Silverbots Robtics Team #2890
 Code:using namespace System;using namespace Genius;using namespace Personality;public ref class Nerd : Geek, IAnserable{    Geek::Type brainMode = Geek::Type::Programmer;}

Sun Aug 23, 2009 8:06 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 2 posts ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

 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