This paper deals with the problem of limit cycles for the whirling pendulum equation ẋ = y, ẏ = sin x(cos x-r) under piecewise smooth perturbations of polynomials of cos x, sin x and y of degree n with the switching line x = 0. The upper bounds of the number of limit cycles in both the oscillatory and the rotary regions are obtained by using the Picard-Fuchs equations which the generating functions of the associated first order Melnikov functions satisfy. Further, the exact bound of a special case is given by using the Chebyshev system.