View unanswered posts | View active topics It is currently Fri Oct 30, 2020 4:21 am

Reply to topic  [ 3 posts ] 
Need help with a repeated task 
Author Message

Joined: Sun Dec 09, 2012 8:42 pm
Posts: 1
Post Need help with a repeated task

Im very new to using robotc. Im using robotc 2.0 and I am wondering if there is a code that will be autonomous and everytime a touch sensor is released the motor starts for 5 seconds and then stops.. if the touch sensor is pressed it resets this process allowing the whole thing to start over if it is released.

If someone could post a code it would be greatly appreciated as I have no clue where to start


Sun Dec 09, 2012 8:46 pm
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 722
Post Re: Need help with a repeated task
I would suggest taking a look through our VEX Cortex Video Trainer using ROBOTC as it goes over some very important and useful programming tools in ROBOTC, such as infinite while loops, conditional statements, motor control commands, and wait statements (all of which will probably be needed in your code). The video trainers will help you understand ROBOTC (and coding in general) better, as they walk you through several programs ranging from basic movement all the way up to advanced functions and remote control.

Check out our Blog! And our Facebook page!
Need help? Take a look at our updated help documentation and the ROBOTC Forums.

Mon Dec 10, 2012 3:09 pm

Joined: Sun Jul 10, 2011 3:34 pm
Posts: 30
Post Re: Need help with a repeated task
I was where you were at one time, so I feel for you. Don't get dicouraged when you run into stuff like this! This is very easy. you have to use something called funcitons. ROBOTC defaults to autonomous mode, so you never have to say anything in the code to indicate autonomous mode.

It should work, but let me know if it doesn't....

#pragma config(Sensor, dgtl1, name_of_touchsensor, sensorTouch)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

void stop_for_5sec ()

task main()

if(SensorValue(name_of_touch sensor)==0)


Wed Dec 12, 2012 8:44 am
Display posts from previous:  Sort by  
Reply to topic   [ 3 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.