programming

I need help programming an ultrasound sensor.

Are you using robotC? If so, I’m glad to help

I am using robotC for cortex.

I assume you know how to set it up in the “motor and sensor setup” menu. Name the sensor distance_sensor" and use this


variable = SensorValue[distance_sensor];

does the command need a while or if loop?

No

thanks

Just to clarify. If you want to refer to the ultrasonic sensor’s new data you either need to refer to the sensorValue[distance_sensor] whenever you want it or update your variable every time you want to read from it.

How do you program a match controller?

Uhh, I am not sure what you are asking. Could you clarify?

I meant to say VEXnet competition switch.

So the switch doesn’t have to be programmed. It has switches on it you flip.

So it will automatically change modes?

Assuming you mean

You have to flip the physical switches.

So the robot will automatically change modes?

It will automatically change modes based on the Competition Switch setting. It will not change modes based on any sort of internal timer, if that’s what you’re asking.

But only if you have a competition template. If you don’t tell your code to care about what mode it is in, it won’t.

What is the code for the VEXnet competition switch?

Its a physical switch that switches between the modes in the competition template.

What is the competition template.