The main goal of robot swarm is to maintain formation among their members while avoiding obstacles and tracking a target in the surrounding environment. One popular approach for achieving this goal is the Potential Field Method (PFM). Thus, in this paper, we propose a formation control algorithm based on the PFM and Fuzzy Inference System (FIS). The Proposed PFM is intended to maintain formation, avoid obstacles and track a moving target as well. We add an interaction potential force to maintain formation beside the attractive and repulsive potential forces. Also, we use the FIS to adapt the change of the relative distances among robots in the swam and other entities int he environment. To test the scalability and reliability of the proposed formation control algorithm, simulations of robot swarms using MATLAB software with a different number of robots following different target trajectories in different environment setups are recorded. Results confirm the efficiency and the applicability the proposed formation control algorithm in achieving the three tasks of the robot swarm.