In this research work, we focus on optimizing urban traffic at a single intersection. Based on the principle of the Internet of Things (IoT), some sensors can be deployed in different locations in the road network and the traffic controller system may collect in real-time the pertinent information about the traffic stat. In this regard, a new approach that dynamically decides the phases sequence and green light times is proposed to improve the traffic quality. Any decision is made according to both Average Waiting Time (AWT) and number of vehicles in the different phases’ queues. Thus, the priority is given to the phase with highest values of AWT and queue size. In order to measure the performances of our approach, we developed a traffic simulation by using NetLogo platform. By varying the traffic density, the proposed approach can efficiently improve the quality of the traffic while minimizing the waiting time of vehicles at intersection and enhancing the traffic flow.