|
Page 1 of 1
|
[ 4 posts ] |
|
| Author |
Message |
|
acash3
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 |
|
 |
|
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 509 Location: Totally not spying on Hassenplug to see what he has for the Brickworld Chicago 2013 sumo contest.
|
 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 |
|
 |
|
acash3
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
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 |
|
 |
|
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 509 Location: Totally not spying on Hassenplug to see what he has for the Brickworld Chicago 2013 sumo contest.
|
 Re: Student doing fail
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 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 |
|
|
|
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 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
|
|