pxt-calliope/docs/projects/flashing-heart.md

105 lines
1.5 KiB
Markdown
Raw Normal View History

2016-06-14 11:12:13 -04:00
# flashing heart
2016-06-14 12:11:29 -04:00
### ~avatar avatar
Use the LEDs to display a flashing heart, and then create
an animation of a broken heart. :(
### ~
2016-05-27 21:40:59 -07:00
## Step 1
Use [show leds](/reference/basic/show-leds) and make your code look like this:
2016-05-27 21:40:59 -07:00
```blocks
basic.showLeds(`
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`
);
2016-05-27 21:40:59 -07:00
```
## Step 2
Add a [pause](/reference/basic/pause) to wait and [clear screen](/reference/basic/clear-screen) to turn off the LEDs.
2016-05-27 21:40:59 -07:00
```blocks
basic.showLeds(`
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`);
2016-05-27 21:40:59 -07:00
basic.pause(500);
basic.clearScreen();
2016-06-10 23:09:18 -04:00
```
## Step 3
Put a [forever loop](/reference/basic/forever) around it.
```blocks
basic.forever(() => {
basic.showLeds(`
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`
);
2016-06-10 23:09:18 -04:00
basic.pause(500);
basic.clearScreen();
})
2016-06-11 14:40:09 -04:00
```
## Step 4
Add a [pause](/reference/basic/pause) to wait after clearing the screen.
```blocks
basic.forever(() => {
basic.showLeds(`
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`
);
2016-06-11 14:40:09 -04:00
basic.pause(500);
basic.clearScreen();
basic.pause(500);
})
```
## Step 5
Add a second image of a broken heart.
```blocks
basic.forever(() => {
basic.showLeds(`
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`
);
2016-06-11 14:40:09 -04:00
basic.pause(500);
basic.clearScreen();
basic.pause(500);
basic.showLeds(`
. # . # .
# . # # #
# . . . #
. # # # .
. . # . .`
);
2016-06-11 14:40:09 -04:00
basic.pause(500);
basic.clearScreen();
basic.pause(500);
})
2016-06-25 17:22:50 -04:00
```