Formations or groups of robots become essential in cases where a single robot is insufficient to satisfy a given task. With an increasingly automated world, studies on various topics related to robotics have been carried out in both the industrial and academic arenas. In this paper, the control of the formation of differential mobile robots based on the leader-follower approach is presented. The leader's movement is based on the least cost path obtained by the A-star algorithm, thus ensuring a safe and shortest possible route for the leader. Follower robots track the leader's position in real time. Based on this information and the desired distance and angle values, the leader robot is followed. To ensure that the followers do not collide with each other and with the obstacles in the environment, a controller based on Artificial Potential Fields is designed. Stability analysis using Lyapunov theory is performed on the linearized model of the system. To verify the implemented technique, a simulator was designed using the MATLAB programming language. Seven experiments are conducted under different conditions to show the performance of the approach. The distance and orientation errors are less than 0.1 meters and 0.1 radians, respectively. Overall, mobile robots are able to reach the goal position, maintaining the desired formation, in finite time.