This paper presents a way to optimize the program of a sliding mode control implemented in a microcontroller, which incorporates an analog comparator as an internal peripheral. The main idea is "to save" microcontroller processing capability by avoiding the use of the analog to digital converter. This saved capability can be used for other tasks that depend in the application. In our case, the saved processing capability was used to generate the necessary signals to control an integrated ballast. The ballast selected as an example is a non-resonant ballast that integrates in a single stage a full-bridge inverter and a Buck converter. This ballast is responsible for feeding an HID lamp with alternating current, and it is also responsible for stabilizing its current. Therefore, the control signals necessary to achieve both tasks are more complicated than those signals which are used to control an ordinary full-bridge inverter. The proposed algorithm for the sliding mode control is a good alternative for applications where power converters are used. Experimental results are shown.