How do I program the software for a sonar sensor?
Setup the sonar sensor in the motors & sensors dialog.
read values from the sonar using the SensorValue function. There are examples included with robotc, you can find these using the “open sample program” in the file menu, there’s also some more information here.
http://www.robotc.net/wikiarchive/VEX2_Sensors_Overview#Sonar