Many accidents occur during the night due to the improper visibility of the road ahead. One of the main reasons is of the discomfort posed by the high beam light of the oncoming vehicle, glares our eyes while driving. This discomfort might result in a lapse of concentration thereby resulting in an accident. Our primary aim is to automatically detect the head light using tracking and segmenting the frames extracted from the video signals that are fed by a camera and automatically switch the lighting condition of our vehicle from low beam to high beam or vice versa to avoid discomfort to the driver of the oncoming vehicle. We use MATLAB to simulate the results of our algorithm. In MATLAB, we mainly use computer vision and image processing to make necessary alterations to the input to get the necessary output.