활동

초급 | MakeCode, Python | LED, 가속도 센서, 버튼, 사운드 | 반복 실행, 선택 실행, 센서, 순차 실행, 입력/출력

## 1단계: 만들어 보세요.

### 프로젝트 소개

Start discovering some of the things the BBC micro:bit can do with this interactive investigation.

These two videos show you what it does and how to code it:

### 설명

You can use this project as an introductory exploration activity for anyone new to the micro:bit.

Copy the code on to some micro:bits, and start investigating what it does. What events make the micro:bit respond? What inputs and outputs is it using? What programming concepts might be making it work?

Then examine the code to see how instructions in code blocks tell the micro:bit what to do:

• Instructions in the ‘on start’ block run once only, when the micro:bit is reset or is powered on. The 'show icon' block shows a happy face on the LED display output.
• Events make different things happen when you press different input buttons. The 'on button A pressed' block is triggered when you press button A. Your micro:bit then shows a square zooming in quickly, then zooming out more slowly.
• The animation is made by showing different images in a sequence. Pausing for shorter and longer times controls the speed of the animation.
• Pressing button B shows how the micro:bit can scroll text on the LED display output using the 'show string' block. 'Strings' are what we call collections of letters and symbols stored in a computer.
• Press button A and B together to reveal a puzzle. You'll either see a sun or a moon. Can you work out what determines which picture is shown?
• It depends how much light is falling on your micro:bit. The micro:bit's LED output can also work as an input, a light sensor.
• The code uses an 'if... then... else' statement. This is known as selection, or a conditional statement. It tests if the light level is below 50. If it is, then it shows a sun. Otherwise, else, it shows a moon.
• The 'on shake' block reacts to information from the micro:bit's accelerometer sensor input. When you shake your micro:bit, it shows a surprised face for one second.
• If you have a micro:bit V2 or connect headphones or a speaker to your micro:bit, you'll also hear different sounds when each different input event happens.

### 준비물

• At least one micro:bit for every 2-3 people
• Battery packs (optional)
• Headphones and crocodile clip leads to hear sound on micro:bit V1 (optional)

You may also find our Set up guide useful to learn more about how to transfer code from the editor to a real micro:bit.