Manipulate an objects rotation

I am using the accelerometer to control my object, it sits in one spot and the accelerometer controls its rotation, turning left and right. At the moment, it spins the entire way around, doing a 360.

What I would like is to limit its turning so that I can never look behind my object, hopefully the code explains it better:

//This turns the object but allows 360 turning
var accelDirection = Input.acceleration.x; 
			transform.Rotate(Vector3.up * accelDirection * 5);

//I would like something like
if(myObject.transform.rotation >= 90)
    //Stop turning

As it stands, the editor is saying I can’t compare a Quaternion and an int (obviously), so is there a way I can set up what I’m looking to achieve?

Any help would be appreciated

‘transform.rotation’ is a quaternion, and it’s x, y, z, and w values are not angles. You can use transform.eulerAngles as long as you are only rotating on the ‘y’ axis.