iPad rotation/orientation

I’m trying to support both right and left landscape orientations. The problem is that when testing my game on a iPad, leaving the iPad laying flat on the table makes it flip constantly between both orientations (this does not happen when testing with an iPhone).
This makes the game unplayable unless you hold the iPad somehow tilted. Here’s the code I’m currently, what can I change to prevent this problem?

		if ((Input.deviceOrientation == DeviceOrientation.LandscapeLeft)  (Screen.orientation != ScreenOrientation.LandscapeLeft))
		{ 
			Screen.orientation = ScreenOrientation.LandscapeLeft; 
		}
	
		if ((Input.deviceOrientation == DeviceOrientation.LandscapeRight)  (Screen.orientation != ScreenOrientation.LandscapeRight))
		{ 
				Screen.orientation = ScreenOrientation.LandscapeRight; 
		}

did you try to set supported orientations in Player Settings? While testing them i had ipad laying down on my table - and it was flipping at most once (when starting)

I fixed it by enabling the autoRotation property, instead of manually doing it, now it works great!