This paper aims to design an accurate angular position control for DC motors using a proportional integral derivative (PID) controller. The estimated DC motor parameters have been calculated using the parameter estimator toolbox in MATLAB, Arduino Mega 2560 and speed sensor to build an accurate model in MATLAB. The optimized PID coefficients are found for the DC motor model using the firefly algorithm (FA), which aims to make the actual angle match the desired value without overshooting and oscillations. The PIC16F877A microcontroller was used to implement the code based on optimized PID coefficients found in MATLAB/Simulink to generate the suitable pulse width modulation (PWM) output. In this work, step input was tested to analyze the characteristics of the system response in terms of rise time, settling time and overshoot. It was found that the controller output response curve which is produced from FA-based-PID reached the desired position without overshoot and any oscillations. The findings established that closed-loop control of any system using a system identification toolbox and optimized PID technique can be applied in real applications using low-cost controllers and sensors such as PIC16F877A microcontroller and analog rotary position sensor, respectively.