This document describes developing a distance algorithm for adaptive cruise control systems using vehicle-to-vehicle communication and sensor networks. It involves three modes: 1) cruise control, 2) adaptive cruise control where the rear vehicle automatically adjusts its speed based on the distance to the preceding vehicle, and 3) cooperative adaptive cruise control where the rear vehicle adjusts its speed and communicates with the preceding vehicle. Ultrasonic sensors measure the distance between vehicles and different distance limits are set for the modes. The system is intended to increase road safety and efficiency by enabling vehicles to automatically control speed based on surrounding traffic conditions.