Piezoelectric ceramics are used in many areas of applications. One of such areas of applications is in controlling electronic devices for accuracy and improved precision. Piezoelectric ceramics however have the problem of inherent high resonance frequency resulting in the piezoelectric ceramic suffering from hysteresis and delay in response to input parameters. PID controllers have been used in providing improved control and response to the piezoelectric ceramic so as to overcome the problem of hysteresis as well as the inherent high resonance frequency and slow response of the piezoelectric ceramic. However, PID controllers have the problem of overshoot as a result of sub-optimal selection of PID tuning parameters. PID controllers also take a long time in adjusting to changes due to error. This paper presents a firefly algorithm based PID controller (F-PID) for minimizing the effect of hysteresis in piezoelectric ceramics and also improving the response of the PID controller.