How to rotate object back and forth from one rotation to another?

I figured I could use something like an IENumerator but I want the object to rotate back and forth from two set positions every x seconds. Thanks for any help

I know this answer is too late for you, but hope this helps anyone else with the same problem in the future!

        public float speed = 2f;
        public float maxRotation = 45f;
        void Update()
            transform.rotation = Quaternion.Euler(maxRotation * Mathf.Sin(Time.time * speed), 0f, 0f);

The rotation thing doesn’t rotate, it grows and shrinks the object.