To improve the smart car’s ability of pre-judgment to the road, this paper studied the application of identifying the path by using the camera, put out a kind of general control algorithm. On sampling images accurately,it obtained the true information of the road by using image restoration techniques and picked up the effective information of the road by using neighbor extraction method. So the trend of black-line and the current position the car against the center of black-line was figured out,and the information for road styles was classified and optimized. Experiments show that the different frequency of PWM can greatly reduce speed up and down the time,a Bang-Bang control algorithms gets the desired speed value.