Challenge: Sense the world around you in Swift Playgrounds – Discover

Like our senses, our devices are constantly collecting data from their environment and can use this information to do interesting and important things. In this challenge, you take advantage of your iPad’s sensor data to create a visualization or experience of your choice.

Start the challenge

To get started, download and open Swift Playgrounds on your iPad, then select View All in the lower right corner to launch the Swift Playgrounds content screen. From here you can find the book Sensor Create under “Starting points” and download a copy to your device.

Fast playground content on iPad

In this challenge you use the Sensor Create playground book to collect 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 device’s motion sensor. The book has good reference material to help you get started: Check out “Using Device Exercise”, “Using Light to Play Audio”, “Clappy Fish” and “Synesthesia”.

Think about the types of things you can suggest about your environment based on this sensor data. Given this, how can you write a code that visualizes this information in interesting ways? For example, you can create an alarm that goes off when the volume around you is too high, or create a message that appears when you accelerate or brake quickly and ask if you or your device has dropped. These are just examples: Use your imagination and come up with an idea you love!


Download Swift Playgrounds for iOS

Learn more about Swift Playgrounds

Read the terms and conditions of WWDC21 Challenges

Leave a Comment