View unanswered posts | View active topics It is currently Fri Aug 26, 2016 1:28 pm

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Student doing fail
Author Message
Rookie

Joined: Mon Apr 23, 2012 9:57 am
Posts: 2
Student doing fail
Hey, folks. Sorry about barging in and all. I've got quite the predicament on my hand. I'm trying to program a robotic car with two motors (left and right), and 3 sensors (2 limitswitches, 1 bumpswitch). Using only these, I am to design a car that moves forward and back for a set time, and keeps going in a loop UNTIL either the limitswitches or the bumpswitch is pressed. If the limitswitches press, it immediately moves in the opposite direction (the limitswitches are on either the front or back of the vehicle), and if the bumpswitch is pressed, the task ends altogether. Is there a specific code I'm missing?

Whenever I try adding a timer-based code (to make a loop), I run into problems. I also can't seem to get the limitswitches or bumpswitches to correlate with the tasks properly (yes, everything's plugged in and powered at the right places).

If I could get some help, that'd be great.

Mon Apr 23, 2012 10:00 am
Senior Roboticist

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Re: Student doing fail

_________________
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 Apr 23, 2012 10:04 am
Rookie

Joined: Mon Apr 23, 2012 9:57 am
Posts: 2
Re: Student doing fail
Bear in mind that I'm absolutely new to programming. TT__TT

{ //Program begins, insert code within curly braces
untilBump(bumpSwitch);
if(limitSwitch1==1){
startMotor(leftMotor,67);
startMotor(rightMotor,-67);}
else{
startMotor(leftMotor,67);
startMotor(rightMotor,-67);
wait(1);
stopMotor(leftMotor);
stopMotor(rightMotor);
wait(1);
startMotor(leftMotor,-67);
startMotor(rightMotor,67);
wait(3);
stopMotor(leftMotor);
stopMotor(rightMotor);
}
}

The number of times I've tried using timers and other limitswitches has been fail-tastic. I've gone back to using a single limitswitch, but right now, all it's doing is following the wait programs for the motors. It's ignoring anything else.

Mon Apr 23, 2012 10:19 am
Senior Roboticist

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Re: Student doing fail
 acash3 wrote:Bear in mind that I'm absolutely new to programming. TT__TTtask main(){ //Program begins, insert code within curly bracesuntilBump(bumpSwitch);if(limitSwitch1==1){ startMotor(leftMotor,67); startMotor(rightMotor,-67);}else{ startMotor(leftMotor,67);startMotor(rightMotor,-67);wait(1);stopMotor(leftMotor);stopMotor(rightMotor);wait(1);startMotor(leftMotor,-67);startMotor(rightMotor,67);wait(3);stopMotor(leftMotor);stopMotor(rightMotor);}}The number of times I've tried using timers and other limitswitches has been fail-tastic. I've gone back to using a single limitswitch, but right now, all it's doing is following the wait programs for the motors. It's ignoring anything else.

Ummm, it appears to me that this isn't RobotC code. Are you sure that your're using RobotC? This looks more like NXC to me.

Oh, BTW, when posting code, please put it in between the

 Code:[code][/code]

_________________
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 Apr 23, 2012 10:57 am
Display posts from previous:  Sort by
 Page 1 of 1 [ 4 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