let motion = CMMotionManager() override func viewDidLoad() { super.viewDidLoad() motion.accelerometerUpdateInterval = 1.0; motion.startAccelerometerUpdates(to: OperationQueue.current!, withHandler: { (data, error) in self.getOrientation( x:(data?.acceleration.x)!, y:(data?.acceleration.y)! ) }) } func getOrientation(x: Double, y: Double) { if (fabs(x) < 0.5) { if (y < 0) { print( "right" ) } else