2 Questions - Jumpers and Repeat

I have 2 questions I hope I am able to ask clearly

  1. Concerning the Jumpers… when a jumper is placed in a Digital I/O port, is it then sending the value “1” or something else?

  2. Concerning the command Repeat is the proper formatting

Repeat ( number of times to repeat)
{
Stuff to repeat
}

Thanks in advance

I don’t know the answer to #2 but in regards to #1 I believe it is sending a value of 1. Since its a value of 1 you can use it to choose things like which auton to run and lots of other things :slight_smile:

Thanks. That will save some time.

I haven’t had time to look into #2 but it just occurred to me that you can accomplish the same thing with a while loop. Like this:

while(something is or isn't true)
{
The stuff you want repeated
}

You have your while loop and in order for this to work you could have something that changes at the end of your Loop so that it exits out once that condition is true or false or you can create an integer and use that to decide how long the program runs like this:


Int number = 1;//declare the integer
while (number < 5)//while the integer is less     //than five
{
The stuff you want repeated
}
Number++;//add 1 to the number each time the loop happens

Something like this should work to make the loop run 5 times and then have it shut off.
I know this isn’t exactly what you’re looking for but if you needed an answer then this can at least help some (hopefully) :slight_smile:

You need to increment inside the while loop.

Oops. Thanks for catching that

  Int number = 1;//declare the integer
while (number < 5)//while the integer is less     //than five
{
The stuff you want repeated

Number++;//add 1 to the number each time the loop happens 
}

There you go :slight_smile:

You are looking to make a for loop


	for (int i, i < 5, i++) // declare an integer and increment it a set number of times
	{
		// do something 5 times
	}

His code of
Repeat(5){

}
Works the same way. It is a ROBOTC natural language feature. Check out an example here
http://www.robotc.net/blog/tag/natural-language/

At the OP, not sure about 1 but your code in 2 works like you expect it to.

Yes, the Repeat command did work as I expected. My students played with it last night and got it working fairly easily. For middle school kids using Robot C, it’s probably an easier concept than a while loop with an incrementing counter.

Thanks all for the suggestions