pxt-calliope/docs/projects/flashing-heart.md
2016-10-13 11:32:25 -07:00

1.7 KiB

flashing heart

~avatar avatar

basic.forever(() => {
basic.showLeds(`
    . # . # .
    # # # # #
    # # # # #
    . # # # .
    . . # . .`
    );
basic.pause(500);
basic.clearScreen();
basic.pause(500);
})

Use the LEDs to display a flashing heart, and then create an animation of a broken heart. :(

~

Step 1

Use show leds and make your code look like this:

basic.showLeds(`
    . # . # .
    # # # # #
    # # # # #
    . # # # .
    . . # . .`
    );

Step 2

Add a pause to wait and clear screen to turn off the LEDs.

basic.showLeds(`
    . # . # .
    # # # # #
    # # # # #
    . # # # .
    . . # . .`);
basic.pause(500);
basic.clearScreen();

Step 3

Put a forever loop around it.

basic.forever(() => {
basic.showLeds(`
    . # . # .
    # # # # #
    # # # # #
    . # # # .
    . . # . .`
    );
basic.pause(500);
basic.clearScreen();
})

Step 4

Add a pause to wait after clearing the screen.

basic.forever(() => {
basic.showLeds(`
    . # . # .
    # # # # #
    # # # # #
    . # # # .
    . . # . .`
    );
basic.pause(500);
basic.clearScreen();
basic.pause(500);
})

Step 5

Add a second image of a broken heart.

basic.forever(() => {
basic.showLeds(`
    . # . # .
    # # # # #
    # # # # #
    . # # # .
    . . # . .`
    );
basic.pause(500);
basic.clearScreen();
basic.pause(500);
basic.showLeds(`
    . # . # .
    # . # # #
    # . . . #
    . # # # .
    . . # . .`
    );
basic.pause(500);
basic.clearScreen();
basic.pause(500);
})