This paper presents a stair detection algorithm for a tri-star wheeled robot, which includes a unique mechanism enabling it to autonomously climb stairs using a sensor-based approach. The algorithm utilizes two motor-driven ultrasonic sensors to detect stair conditions and safely switch between rolling, ascending, and descending states. Experimental validation demonstrates the effectiveness of the robot in navigating various stair environments, while highlighting the limitations of the system's adaptability to different stair designs.