Survival in the Arctic Coding Tutorial

如果想看中文版的話請按這裏

Please click here for Chinese version.

In this tutorial, you will learn how to do coding for the interactive shelter model of Survival in the Arctic. Interactive model means the model will interact with the user in certain scenario. In this model, we will give a night scenario for it, since Klippers and his friends need to stay in the dark arctic for a night. In every coding, we need to identify the input and output first, since the scenario is night, we are going to use darkness as the input of the code. Therefore we need to use a Light sensor to sense the brightness, while in the meantime we hope to create a campfire effect and wind sound as a output, so we need to use a RGB LED and a sound player.

1. Please connect a Key Press and a RGB LED.

2. Go to the setting of the RGB LED and set the colour of it as Red. This LED will represent the fire.

3. Connect an Interval between the Key Press and RGB LED. The reason of using an interval is because we need to create the flashing effect of fire, while using an interval allows the LED to light up and off every certain time, creating the flashing effect.

4. Go to the setting of Interval and set the time trigger as 500 milliseconds. In this case, the LED will light up and off every half second.

5. Connect a Sound Player to the Key Press so that we can use sound to simulate the environment of arctic, in order to increase the interactivity and realisticity of the model.

6. Go to the setting of Sound Player, set the category as Weather and choose Wind (normal) for the sound. This will let the wind sound being played together with the LED light on.

7. Replace the Keypress with a Light sensor. After that, connect a Compare command after the Light sensor. This command turns the Light Sensor into an input by using the light intensity value to compare with a fixed value. This comparison will become the start of the whole program since it means the dark night scenario that we talked about at first. All the following outputs including the light and sound will only occur when the scenario matches.

8. Go to the setting of Compare and change the value from "=60" to "<30". This means when the value from Light Sensor is lower than 30, the program will determine the situation as "True", and will continue on the following actions. If the value is higher than 30, it will be determined as "Not True" (In programming language, we usually say not true instead of false), and nothing will happen. The purpose of using a light sensor is to check if the environment is a dark scenario or not, and since the value of light sensor should not be higher than 30 in dark environment, 30 can become the value to determine if the environment is dark or not.

9. The coding for this interactive model is done. Now try to cover the Light sensor with your hand and let the value lower than 30. You will see the LED red light starts flashing while the sound player is playing a wind sound. Together with the Shelter model, you simulated the scene of Survival in the Arctics.