View unanswered posts | View active topics It is currently Sat Sep 26, 2020 12:48 am

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Arrays in RobotC
Author Message
Rookie

Joined: Sat Jan 02, 2016 5:22 am
Posts: 2
Arrays in RobotC
Hello!
The robot has one wheel at the back and this wheel is attached to a motor. It drives forward and if i would clap once, it would turn left. If I would clap two times it would go right and three times would mean that the wheel would go back straight. I have created an array for this that counts number of claps. If i clap once there is one variable in an array, two times there are two and so on. The problem is that then i have to check how many of these variables the array contains but i don't know how to do this. Can somebody help me with this?

Sat Jan 02, 2016 5:36 am
Expert

Joined: Thu Dec 01, 2011 12:07 am
Posts: 151
Re: Arrays in RobotC
Try to use the code format if you can.

Sat Jan 02, 2016 11:49 pm
Moderator

Joined: Tue May 19, 2015 3:07 pm
Posts: 91
Re: Arrays in RobotC
 hehahe wrote:Hello!The robot has one wheel at the back and this wheel is attached to a motor. It drives forward and if i would clap once, it would turn left. If I would clap two times it would go right and three times would mean that the wheel would go back straight. I have created an array for this that counts number of claps. If i clap once there is one variable in an array, two times there are two and so on. The problem is that then i have to check how many of these variables the array contains but i don't know how to do this. Can somebody help me with this?

Okay so to answer your question the simplest is going to be a for loop, a for loop is a limited loop that is designed to run a discrete number of times while maintaining the count of its location as it parses.
 Code:task main(){   const int arrayLength=5;   int counter;   int toParse[arrayLength] = {0,0,0,0,0};   for(int i=0;i

My question is there a reason you don't just use whatever counts the claps to increment a variable directly rather than fill the array? I guess the question is do you plan on using the values in the array or just the fact that you put something there?

Fri Jan 08, 2016 1:48 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 3 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