View unanswered posts | View active topics It is currently Sat Oct 25, 2014 10:33 am






Reply to topic  [ 4 posts ] 
Student doing fail 
Author Message
Rookie

Joined: Mon Apr 23, 2012 9:57 am
Posts: 2
Post 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
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Student doing fail
What code have you got so far? The more information you give, the more help you're likely to get.

_________________
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
Profile WWW
Rookie

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

task main()
{ //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
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Student doing fail
acash3 wrote:
Bear in mind that I'm absolutely new to programming. TT__TT

task main()
{ //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.


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]


tags for better readablity

_________________
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
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 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.