Fuzzy logic control is the most common method utilized to tune proportional integral derivative (PID) controller parameters online. However, proportional integral derivative controllers often perform poorly in the control of nonlinear and/or complicated systems, such as direct current motors, where the model parameters are not exactly known if the scaling factors are not properly selected besides the membership function and rule sets in a fuzzy logic controller design. Finding the most suitable scaling factors for complex systems where the model parameters are not exactly known or nonlinear systems is a challenging task. Furthermore, traditional trial and error techniques of determining appropriate scaling factors are experience based, time consuming, and may not always provide optimal response. In this paper, a particle swarm optimization algorithm is suggested for optimizing the input and output gains of the fuzzy PID controller. The robustness and effectiveness of the suggested controller was validated using MATLAB/Simulink. The performance of the suggested controller is compared with the Ziegler Nichols and Particle Swarm Optimization Algorithm tuned PIDs, and fuzzy PID controllers. The simulation result show that the fuzzy PID controller whose scaling factor was tuned using particle swarm optimization outperforms the other controllers in avoiding disturbance and has a better trajectory tracking capability.