In Wireless Sensor Networks, the traffic is light under idle or light load. When an event is detected the network becomes active and the data flow traffic becomes heavy, which leads to congestion. Congestion plays an vital role in reducing the performance of the network. Hence it necessitates to develop an effective congestion control technique. This paper focus on congestion detection and control technique. We have proposed a new algorithm to detect and control congestion in a Wireless Sensor Network. The congestion is detected by measuring the length of the queue. The queue length increases when the Packet inter-arrival time is more than Packet inter-service time. Using queue length, the Buffer Occupancy is calculated. When the Buffer Occupancy increases, the congestion increases. Thus the network is prone to congestion. Congestion is controlled by assigning priority to the data packets. When the Buffer Occupancy increses, the data packets are dropped depending on priority assigned to the data packets i.e Intelligent Packet Dropping. Depending on Buffer Occupancy, level of congestion is analyzed and it is controlled. This technique is implemented successfully in NS-2 simulator. Performance of the network is evaluated by calculating the Packet loss and Packet Delivery Ratio and the system is implemented successfully.