Reading serial data from maxSonar ultrasonic rangefinder

Thanks so much to Goldthing for posting a solution to reading serial output from Maxbotix MaxSonar ultrasonic rangefinder/proximity sensors on Arduino boards. I am doing a project with the MB1200 XL-MaxSonar-EZ0, pairing it with a proprietary LED panel with a built in ESP8266 limited to only 2 digital input pins. It was godsend to find out it's possible to flip the signal with SoftwareSerial (as well as see the integer parsing code). Flipping the signal in software is soooo simple and so much better than buying a hardware signal inverter. It took an extended Google dive to find this post but I'm glad I did. I came across a handful of other threads on this topic that died before the problem was resolved.

To add to the discussion, I ran into some LED frame rate issues with the "sonarSerial.available()" calls stalling the code down to 1-2 Hz. I was able to get my frame rate back up by removing "sonarSerial.available()" completely as well as removing "sonarSerial.flush()". This makes for a lot of garbage data, but that's easy enough to filter out with a simple if statement ignoring any readings below 20 centimeters or above 1000 centimeters. These changes also make the range readings stutter a bit, but the irregular updates are still faster than the 1 reading per second I need anyway. Not the greatest software engineering, but this is just for an art project anyway ;).