Challenge: Sense the world around you in Swift Playgrounds
June 9, 2021
Just like our senses, our devices constantly gather data from their environment, and can use that information to do interesting and important things. In this challenge, you'll harness your iPad’s sensor data to create a visualization or experience of your choosing.
Begin the challenge
To get started, download and open Swift Playgrounds on your iPad, then select See All from the lower right corner to launch the Swift Playgrounds content screen. From here, you can find the Sensor Create book under “Starting Points” and download a copy to your device.
In this challenge, you’ll use the Sensor Create playground book to gather some data from the world around you. You can use audio data (frequency, volume) from the microphone, light data (color, brightness) from the camera, and also gyroscope data (movement in X, Y, Z coordinates) from the motion sensor of the device. The book has some great reference material to help you get started: Check out “Using Device Motion,” “Using Light to Play Sound,” “Clappy Fish,” and “Synesthesia.”
Think about the types of things you could decipher about your environment based upon this sensor data. Given this, how can you write some code that visualizes this information in interesting ways? For example, you could create an alarm that goes off when the volume around you is too high, or create a notification that displays when you quickly accelerate or decelerate, asking if you or your device has fallen. These are just examples: Use your imagination and come up with an idea you love!