Ron Dagdag
Published © MIT

Celebrate the New Year by Learning Programming

My kids celebrated New Year's Eve learning to code. Here's a simple and fun way to celebrate the New Year countdown.

EasyShowcase (no instructions)1 hour174
Celebrate the New Year by Learning Programming

Things used in this project

Hardware components

BBC micro:bit board
BBC micro:bit board
×1

Software apps and online services

MakeCode
Microsoft MakeCode

Story

Read more

Code

countdown timer

JavaScript
let star2: Image = null
let star1: Image = null
let countingdown = false
let counter = 0
input.onButtonPressed(Button.A, () => {
    counter += 1
})
input.onButtonPressed(Button.B, () => {
    countingdown = true
})
star1 = images.createImage(`
    . . . . .
    . . . . .
    . . # . .
    . . . . .
    . . . . .
    `)
star2 = images.createImage(`
    . . . . .
    . . # . .
    . # # # .
    . . # . .
    . . . . .
    `)
counter = 3
countingdown = false
basic.forever(() => {
    basic.showNumber(counter)
    if (countingdown == true) {
        basic.pause(1000)
        counter += -1
        if (counter <= 0) {
            countingdown = false
            for (let i = 0; i < 4; i++) {
                star1.showImage(0)
                basic.pause(200)
                star2.showImage(0)
                basic.pause(200)
            }
            basic.showString("HAPPY NEW YEAR!")
        }
    }
})

Credits

Ron Dagdag

Ron Dagdag

38 projects • 301 followers
Microsoft MVP / Lead Software Engineer / Augmented Reality. Developer Passionate to learn about Robotics, VR, AR, ML, IOT

Comments

Add projectSign up / LoginAbout BBC micro:bit