Listening to the sounds made by the lungs is a long-standing method that is still used to diagnose lung diseases. Many studies have been conducted on the automatic recognition of recorded sounds from the lungs. However, in these studies, respiratory cycles, i.e. inhalations followed by exhalations, were either monitored manually or by using multichannel signals of the sounds made by the lungs. In order to recognize sounds made by the lungs automatically, one must first use these sounds to determine the respiratory cycles. Our previous study was the first study presented in the literature in which the boundaries of respiratory cycles were determined based on single-channel sounds from the lungs. However, this method was not successful when ambient noise occurred and interfered with the sounds from the lungs. In the present study, a new method has been developed in which important changes were made to reduce or negate the effects of ambient noises. Our proposed new method includes a processing method that we developed to obtain respiratory cycles as smooth, repetitive patterns. Then the dynamic time-warping algorithm was used to determine the boundaries of the respiratory cycles, based on the similarity of the patterns. This new method was used to detect the seven sounds that are commonly made by the lung. As a result, the limits of the respiratory cycles were obtained with a mean absolute error of 56.51 ms. In addition, the method we developed has the potential to determine the boundaries of the patterns in signals that contain repetitive data, such as the sounds made by the lungs in this study.