A ranging device and a ranging method are provided. The ranging device includes a light source, an image sensor, and a processor. The light source projects a plurality of projection patterns onto a surface of an object to be measured at different times. The image sensor senses the surface of the object to be measured in synchronization with projection times of the projection patterns to obtain a plurality of sensing images respectively corresponding to the projection patterns. The processor analyzes the sensing images to determine depth information of the object to be measured. The processor performs trigonometric calculations to obtain the depth information.