Create Compass app in Sketchware
![Image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaqDgrZrY1QDGd9ZGy3J4RCK_rCsVR9hfOxI7I85o-adzTyp65FoE0gpg6sKkfyxRK9ULz8rGHYvkR4U8MGSRMKLGvqRXI9f1JBYp0QdqtP5LduyaNMFqgpY4aykUp-9He0uxMWeOyAEPV/s320/IMG_20210206_224151.jpg)
To create a Compass app in Sketchware, follow the steps given below. 1. In View area add an ImageView imageview1 . Set image of a Compass as it's image. Make sure that North is towards the top. 2. Create a Gyroscope component gyro and another Gyroscope component gyroMagnet . 3. Create a More block extra and put following code in it. } private float[] floatGravity = new float[3]; private float[] floatGeoMagnetic = new float[3]; private float[] floatOrientation = new float[3]; private float[] floatRotationMatrix = new float[9]; { 4. In onCreate event use blocks Gyroscope gyro sensor stop , and Gyroscope gyroMagnet sensor stop . After that put following code in an add source directly block: gyro.registerListener(_ gyro _sensor_listener, gyro.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),SensorManager.SENSOR_DELAY_NORMAL); gyro.registerListener(_ gyroMagnet _sensor_listener, gyro.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD),SensorManager.SENSOR_DELAY_NORMAL); 5. In onPause event