2017-04-05 10:16:47 -07:00
|
|
|
# Flashing Heart
|
2016-05-27 21:40:59 -07:00
|
|
|
|
2018-10-10 15:38:51 -07:00
|
|
|
## Introduction @unplugged
|
|
|
|
|
|
|
|
Learn how to use the LEDs and make a flashing heart!
|
|
|
|
|
|
|
|
![Heart shape in the LEDs](/static/mb/projects/flashing-heart/show-leds.gif)
|
|
|
|
|
2018-10-10 09:00:56 -07:00
|
|
|
## Step 1 @fullscreen
|
2016-05-27 21:40:59 -07:00
|
|
|
|
2018-06-21 16:02:19 -07:00
|
|
|
Place the ``||basic:show leds||`` block in the ``||basic:on start||`` block and draw a heart.
|
2016-05-27 21:40:59 -07:00
|
|
|
|
2017-09-11 10:49:40 -07:00
|
|
|
```blocks
|
2016-05-27 21:40:59 -07:00
|
|
|
basic.showLeds(`
|
2016-10-13 11:32:25 -07:00
|
|
|
. # . # .
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
. # # # .
|
|
|
|
. . # . .`
|
|
|
|
);
|
2016-05-27 21:40:59 -07:00
|
|
|
```
|
|
|
|
|
2018-10-10 09:00:56 -07:00
|
|
|
## Step 2 @fullscreen
|
2016-05-27 21:40:59 -07:00
|
|
|
|
2018-08-17 07:58:45 -07:00
|
|
|
Place another ``||basic:show leds||`` block under the heart to make it blink. Check in the simulator to see the heart blink.
|
2017-04-05 10:16:47 -07:00
|
|
|
|
2017-09-11 10:49:40 -07:00
|
|
|
```blocks
|
2016-05-27 21:40:59 -07:00
|
|
|
basic.showLeds(`
|
2016-10-13 11:32:25 -07:00
|
|
|
. # . # .
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
. # # # .
|
|
|
|
. . # . .`);
|
2017-04-05 10:16:47 -07:00
|
|
|
basic.showLeds(`
|
2018-10-10 15:38:51 -07:00
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .`);
|
2016-06-10 23:09:18 -04:00
|
|
|
```
|
|
|
|
|
2018-10-10 09:00:56 -07:00
|
|
|
## Step 3 @fullscreen
|
2016-06-10 23:09:18 -04:00
|
|
|
|
2018-10-10 15:38:51 -07:00
|
|
|
But we only see the heart blink once. To have it continue to blink, move the blocks inside the ``||basic:forever||`` to make the animation repeat.
|
2016-06-10 23:09:18 -04:00
|
|
|
|
2018-07-08 21:08:21 -07:00
|
|
|
```blocks
|
2016-06-10 23:09:18 -04:00
|
|
|
basic.forever(() => {
|
2016-12-08 00:10:00 -08:00
|
|
|
basic.showLeds(`
|
|
|
|
. # . # .
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
. # # # .
|
|
|
|
. . # . .`
|
|
|
|
);
|
2017-04-05 10:16:47 -07:00
|
|
|
basic.showLeds(`
|
2018-10-10 15:38:51 -07:00
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .`
|
|
|
|
);
|
2016-06-10 23:09:18 -04:00
|
|
|
})
|
2016-06-11 14:40:09 -04:00
|
|
|
```
|
|
|
|
|
2018-10-10 09:00:56 -07:00
|
|
|
## Step 4 @fullscreen
|
2017-04-05 10:16:47 -07:00
|
|
|
|
2018-10-10 15:38:51 -07:00
|
|
|
Now let's get fancy and place more ``||basic:show leds||`` blocks to create your own animation.
|
2017-04-05 10:16:47 -07:00
|
|
|
|
2017-09-11 10:49:40 -07:00
|
|
|
```blocks
|
2016-06-11 14:40:09 -04:00
|
|
|
basic.forever(() => {
|
2016-12-08 00:10:00 -08:00
|
|
|
basic.showLeds(`
|
|
|
|
. # . # .
|
|
|
|
# # # # #
|
|
|
|
# # # # #
|
|
|
|
. # # # .
|
|
|
|
. . # . .`
|
|
|
|
);
|
|
|
|
basic.showLeds(`
|
|
|
|
. # . # .
|
2017-04-05 10:16:47 -07:00
|
|
|
# . # . #
|
|
|
|
# . . . #
|
|
|
|
. # . # .
|
2016-12-08 00:10:00 -08:00
|
|
|
. . # . .`);
|
2017-04-05 10:16:47 -07:00
|
|
|
basic.showLeds(`
|
|
|
|
. . . . .
|
|
|
|
. # . # .
|
|
|
|
. # # # .
|
|
|
|
. . # . .
|
|
|
|
. . . . .`);
|
2016-06-11 14:40:09 -04:00
|
|
|
})
|
2016-06-25 17:22:50 -04:00
|
|
|
```
|
2016-12-08 00:10:00 -08:00
|
|
|
|
2018-10-10 09:00:56 -07:00
|
|
|
## Step 5 @fullscreen
|
2016-12-08 00:10:00 -08:00
|
|
|
|
2018-08-17 07:58:45 -07:00
|
|
|
If you have a @boardname@ connected, click ``|Download|`` to transfer your code and watch the hearts flash!
|