pxt-calliope/docs/tutorials/getting-started.md

70 lines
1.7 KiB
Markdown
Raw Normal View History

# Getting Started
2017-01-01 18:52:22 -08:00
## Step 1
2017-01-01 18:52:22 -08:00
Welcome! Place the ``||basic:show string||`` block in the ``||basic:on start||`` slot. Replace the ``"Hello"`` text with your name. Did you see it scroll in the simulator?
2017-01-01 18:52:22 -08:00
2017-01-06 04:32:53 -08:00
```blocks
2017-03-30 14:14:39 -07:00
basic.showString("Micro!")
2017-01-01 18:52:22 -08:00
```
## Step 2
2017-01-01 18:52:22 -08:00
Well, the text stopped scrolling. Place the ``||basic:show string||`` block in the ``||input:on button pressed||`` slot to scroll your name when button **A** is pressed.
2017-01-01 18:52:22 -08:00
2018-06-01 11:49:48 -07:00
```blocks
2017-01-06 04:32:53 -08:00
input.onButtonPressed(Button.A, () => {
2017-03-30 14:14:39 -07:00
basic.showString("Micro!")
2017-01-06 04:32:53 -08:00
});
2017-01-01 18:52:22 -08:00
```
2017-01-06 04:32:53 -08:00
## Step 3
2017-01-06 04:32:53 -08:00
Place some blocks to display a smiley when button **B** is pressed.
2017-03-30 14:14:39 -07:00
Use the dropdown to find ``B``!
2017-01-01 18:52:22 -08:00
2018-06-01 11:49:48 -07:00
```blocks
2017-01-04 10:06:47 -08:00
input.onButtonPressed(Button.B, () => {
basic.showLeds(`
2017-01-06 04:32:53 -08:00
# # . # #
# # . # #
2017-01-04 10:06:47 -08:00
. . . . .
2017-01-06 04:32:53 -08:00
# . . . #
. # # # .
2017-01-04 10:06:47 -08:00
`)
2017-01-02 22:14:40 -08:00
})
```
## Step 4
2017-01-01 18:52:22 -08:00
Place the ``||basic:show number||`` and ``||Math:pick random||`` blocks in an ``||input:on shake||`` block to build a dice.
2017-03-30 14:14:39 -07:00
```blocks
input.onGesture(Gesture.Shake, () => {
basic.showNumber(Math.randomRange(0, 10))
})
```
2017-03-30 14:14:39 -07:00
## Step 5
A typical dice shows values from `1` to `6`. So, in ``||Math:pick random||``, don't forget to choose the right minimum and maximum values!
2017-01-01 18:52:22 -08:00
2018-06-01 11:49:48 -07:00
```blocks
2017-01-06 04:32:53 -08:00
input.onGesture(Gesture.Shake, () => {
basic.showNumber(Math.randomRange(1, 6))
2017-01-02 22:14:40 -08:00
})
2017-01-01 18:52:22 -08:00
```
## Step 6
If you have a @boardname@, connect a USB cable to it and click ``|Download|``. Save the program to the **@drivename@** drive. This transfers your code to the @boardname@!
## Step 7
On the @boardname@, press button **A** to scroll your text. Press button **B** to show a smiley. Shake the @boardname@ and see which number is chosen.
## Step 8
Well done! You've completed your first Microsoft MakeCode activity.