In the current study of mobile robots, the path planning algorithm and optimization in both static and dynamic situations are the key issues that are being addressed. Path planning can be used to resolve a wide range of issues in a variety of industries. It can direct the robot to arrive at a specific location or destination using very basic trajectory planning to the choice of an appropriate series of actions. The focus of this project is on the algorithms that are used to optimize the path of a mobile robot using MATLAB and other important resources. For static known obstacles, the A* and D* algorithms are described with a suitable justification and mathematical relationships. The PRM (probabilistic roadmap) technique is also covered in this. This algorithm creates a network graph of potential paths in a given map based on free and occupied regions. The robot is initially placed in an area with static known obstacles, and is then assigned to a start and target point. Additionally, waypoints generated by MATLAB are used to provide the robot with instructions so that it can navigate and follow an optimized course while avoiding potential hazards. With regard to time, obstacles, and distance, the optimal path is. Typically, Arduino is used to combine hardware components into software programmes, but in this project, we utilized MATLAB for better computation because it provides accurate optimized paths that are integrated with ESP. As a result, there are fewer hardware and software components, which decreases computing time.