proxcont = sonar.ping_cm();
delay(30); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
Serial.print("distance: ");
Serial.print(sonar.ping_cm()); // Send ping, get distance in cm and print result (0 = outside set distance range)
Serial.println("cm");
You are still calling sonar.ping_cm() twice. The second call, in the Serial.print() argument list should be replaced by proxcont.
You don't need to define a local variable to pass to the SetBrightness() method. You can pass a literal value.
There are two values of proxcont that result in the same block executing. Each block changes the value of the brightness by 5.
So, there is a nearly linear relationship between brightness and proxcont. brightness = 160 - 2.5 * proxcont. No if statements needed, unless you need that stairstep relationship between brightness and proxcont that you have now. (If you do, you can still define brightness in terms of proxcont/2 with a step of 5).