finish second lesson
This commit is contained in:
parent
5a2896808e
commit
346ec3d1a6
@ -1,5 +1,7 @@
|
||||
# Projects
|
||||
|
||||
![](/static/mb/projects/all10.png)
|
||||
|
||||
![](/static/mb/projects/a1-display.png)
|
||||
|
||||
[Flashing Heart](/projects/flashing-heart)
|
||||
|
67
docs/projects/buttons-smiley.md
Normal file
67
docs/projects/buttons-smiley.md
Normal file
@ -0,0 +1,67 @@
|
||||
![](/static/mb/projects/a2-buttons.png)
|
||||
|
||||
Use buttons to show a smiley or frowny face.
|
||||
|
||||
## Step 1
|
||||
|
||||
Use [show leds](/reference/basic/showLeds) to make a smiley face:
|
||||
|
||||
```blocks
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .`);
|
||||
```
|
||||
|
||||
## Step 2
|
||||
|
||||
Add an input block for when [button A is pressed](/reference/input/button-is-pressed), and put a
|
||||
frowny face inside it:
|
||||
|
||||
```blocks
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .`);
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # # # .
|
||||
# . . . #`);
|
||||
});
|
||||
```
|
||||
|
||||
## Step 3
|
||||
|
||||
Now add blocks so that when [button B is pressed](/reference/input/button-is-pressed), a smiley appears:
|
||||
|
||||
```blocks
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .`);
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # # # .
|
||||
# . . . #`);
|
||||
});
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .`);
|
||||
});
|
||||
```
|
@ -45,4 +45,50 @@ basic.showLeds(`
|
||||
basic.pause(500);
|
||||
basic.clearScreen();
|
||||
})
|
||||
```
|
||||
|
||||
## Step 4
|
||||
|
||||
Add a [pause](/reference/basic/pause) to wait after clearing the screen.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .`);
|
||||
basic.pause(500);
|
||||
basic.clearScreen();
|
||||
basic.pause(500);
|
||||
})
|
||||
```
|
||||
|
||||
## Step 5
|
||||
|
||||
Add a second image of a broken heart.
|
||||
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .`);
|
||||
basic.pause(500);
|
||||
basic.clearScreen();
|
||||
basic.pause(500);
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# . # # #
|
||||
# . . . #
|
||||
. # # # .
|
||||
. . # . .`);
|
||||
basic.pause(500);
|
||||
basic.clearScreen();
|
||||
basic.pause(500);
|
||||
})
|
||||
```
|
BIN
docs/static/mb/projects/all10.png
vendored
Normal file
BIN
docs/static/mb/projects/all10.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 186 KiB |
Loading…
Reference in New Issue
Block a user