To protect vulnerable road users (VRU) like children and elderly, this paper presents a new warning system on smartphones. This system has three phases. First, we propose a new geometric approach to activate the system for necessary risky situations. Second, we extract some important features for VRUs and drivers based on their smartphones sensors to estimate the collision risk by using a fuzzy inference engine. Finally, we divide the warning alarms into low risk, medium risk, and high risk. To improve system accuracy, we consider the effects of vehicle acceleration, weather condition, time of day, pedestrian age, and driver age in our system and use 4G wireless communications between VRUs and drivers. Experimental results on 608 samples from six important types of accident situations show that our system for in danger VRUs, has 96% accuracy, 63% recall, and 90% precision. The improvements in accuracy, precision, and F-measure are 5%, 70%, and 42% compared with the previous works. Moreover, the activation phase of our system led to 400-ms reduction in run time while the accuracy improves 22%. Besides, on the random samples extracted from the accident simulator software, the accuracy, recall, and precision of the proposed system improve 98%, 75%, and 60%, which are better than the previous similar systems.