This paper proposes a Control Algorithm with machine learning approach which will control the LEDs to provide precise beam patterns. Adaptive Front-lighting System (AFLS) focuses on automatically controlling the headlamps thereby making the objects visible and provides proper illumination at the night time for drivers, so as to avoid accidents. With this technology in hand, vehicles can adjust intensity and angle of the headlight based on speed or direction of travel to reduce high beam, improve visibility at curves, and improve night time visibility. The headlamp under consideration is an LED based lamp system. The LEDs can be accessed individually and are independent of each other in their operation. The independent and individual control and monitoring of LEDs ensures the realization of all AFLS modes without any aid from external stepper motors and hardware. The software is designed on MATLAB\Simulink platform controls the operation of the lamp as per the input scenario. Inputs from the CAN are operated upon by the model and based on the input status, the model decides the status of LEDs. Our Control Algorithm considers Velocity of the host Vehicle, Steering angle, Camera Input to identify the objects (in front and behind the vehicle) and some more parameters as the input. The results provided in this paper will demonstrate the effectiveness and efficiency of our algorithm in controlling the LEDs. Based on the inputs received, the model algorithm invokes the interface function which ensures individual access of the LEDs producing desired results. However, the MATLAB model designed can only respond to the changes in the environmental and traffic input conditions and not to the conditions which cannot be traced with given set of inputs and is also slow in its response at times. Machine learning is used to train the model for all such conditions.