diff --git a/docs/projects.md b/docs/projects.md index e818640b..f2b103a4 100644 --- a/docs/projects.md +++ b/docs/projects.md @@ -1,5 +1,7 @@ # Projects +![](/static/mb/projects/all10.png) + ![](/static/mb/projects/a1-display.png) [Flashing Heart](/projects/flashing-heart) diff --git a/docs/projects/buttons-smiley.md b/docs/projects/buttons-smiley.md new file mode 100644 index 00000000..680683ca --- /dev/null +++ b/docs/projects/buttons-smiley.md @@ -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(` + . # . # . + . # . # . + . . . . . + # . . . # + . # # # .`); +}); +``` \ No newline at end of file diff --git a/docs/projects/flashing-heart.md b/docs/projects/flashing-heart.md index 0f9155fc..46927f5d 100644 --- a/docs/projects/flashing-heart.md +++ b/docs/projects/flashing-heart.md @@ -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); +}) ``` \ No newline at end of file diff --git a/docs/static/mb/projects/all10.png b/docs/static/mb/projects/all10.png new file mode 100644 index 00000000..c1af1d0e Binary files /dev/null and b/docs/static/mb/projects/all10.png differ