print to console in RobotC

Is the LCD the only way to show a display using RobotC?

Would like to display a counter to a console or screen

You can write to the debug stream.

1 Like

Sometimes the Vexnet keys can’t quite keep up with the data rates, so hooking a USB A-A between cortex and joystick/PC speeds this up and makes the stream data much cleaner.

This applies more to the new style keys but has been seen when logging copious amounts of data to the debug stream in a time slice.

Just be careful about that cord!

I figured out how to run the debug stream window and I have a counter working so that my sorter using a line tracker counts total white, black and total. The range of the line follower seems to be so narrow between white and black that it has a hard time differentiating between the two. The total variance between white and black on the line follower is only 10. Is there a way to set a line tracker so that it has a little greater variance?

It needs to be closer to the lines, 1/8 to 1/4 inch IIRC.

Agreed. You must have the sensors to far away. When we use the line followers there has always been at least a 1000 unit difference between black and white.

The line follower seems to do the opposite. As they get further away the diff. from white to black increases. We currently have them about 1/4" or less. and the difference is only 10 or 20 at the most ??

Not really using them to follow a line, we built a tank track that sorts the white and black disks as they fall off the end of the track. I also am trying to incorporate a counter that counts total black, white and all. We can get the program to count well and can get it to sort well but not both.

This seems odd and not correct. Are you referring to multiple line followers, or just one? Perhaps if it is just one, you might have a bad one?

I recall one time we had three line followers on a robot and ONE of them was responding just as you are describing. We found it to just be faulty.

I apologize for being late to the party on this one, but (as noted above) the Debug Stream is most likely what you will want to use. There’s a couple of key features that you can utilize to make using the Debug Stream easier:

You can automatically open the Debug Stream when a program is compiled and downloaded by adding the #pragma DebuggerWindows(“debugStream”) line to the top of your program (I recommend putting them after the “Code Automatically generated” comment created by the Motors and Sensors Setup Window). You can also find a full list of debugger windows that can be automatically called by a program in the Debugging Via Code page in the ROBOTC Help Documentation.

You also can run the Debug Stream while the Cortex is not connected directly to a computer; when this happens, the debug stream will fill a buffer full of the values that you send to it, which will then be uploaded to ROBOTC the next time the Cortex is connected to a computer. To do so:

  • Create and download your program to the Cortex.
  • Take the Cortex to the field/run the program
  • Without turning the Cortex off, reconnect the Cortex to the computer.
  • Navigate to and select the ‘Robot -> Open Debugger Manually’ menu option in ROBOTC.
  • Navigate to and select the ‘Robot -> Debugger Windows -> Debug Stream’ menu option (if the Debug Stream isn’t already open).

This will cause the Debug Stream to automatically populate with the data from the last program run. In the newest versions (ROBOTC 4.29 and later), you can also save the contents of the Debug Stream to a text file (there is a File->Save menu option in the newer Debug Stream windows).

Finally, there is a new command that can be used to ensure that the Debug Stream buffer isn’t overfilled when the Cortex isn’t connected to the computer:


This command will return the amount of space left in the Debug Stream buffer (in bytes), and can be used in a program to make sure that you don’t accidentally overfill the buffer.

**Example: **

#pragma config(StandardModel, "SWERVEBOT")
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

//Opens Debug Stream Window automatically
#pragma DebuggerWindows("DebugStream")

task main()
	//Clears Debug Stream before use

	//While there are at least 100 bytes available in the buffer
	while(getAvailSpaceInDebugStream() >100)
		//Write the value of the Sonar sensor to it
		writeDebugStreamLine("Value: %d", SensorValue(sonarCM));
1 Like