Sonar Sensor

Is there a special program to define your variables for a sonar sensor?

I’m not exactly sure what you are asking, however, the sonar sensor is setup in the motors & sensors dialog. Values are read from the sonar using the SensorValue intrinsic. There are example programs for the sonar sensor in the “Ultrasonic Range module” folder, select open sample program from the file menu.