This was my final project during my robotics class in 2017 at Ashesi University College. I implemeneted a simplified occupancy grid algorithm for low-cost robot example is LEGO MINDSTORMS EV3 https://www.lego.com/en-us/mindstorms/products/mindstorms-ev3-31313.
The implementation was motivated by a paper by David Gonzalez-Arjona, Alberto Sanchez, Fernando Lo ́pez-Colino, Angel de Castro and Javier Garrido title Simplified Occupancy Grid Indoor Mapping Optimized for Low-Cost Robots
Feel free to do anything with the code and also offer suggestions if you wish.