Learn Makecode - 10 Code Examples & CST Typing Practice Test
Microsoft MakeCode is a block- and text-based coding platform for creating interactive programs, games, and hardware projects using microcontrollers like micro:bit, Circuit Playground Express, and more.
Code Sample Descriptions
Hello World in MakeCode (JavaScript view)
basic.showString("Hello World")
A simple MakeCode project that shows 'Hello World' on the micro:bit LED display. Blocks generate the JavaScript code below.
Scroll Text on micro:bit
basic.showString("Welcome!")
Scrolls a custom message on the micro:bit LED display.
Display a Heart Icon
basic.showIcon(IconNames.Heart)
Shows a heart icon on the micro:bit LED display.
Blink an LED
basic.forever(function () {
led.toggle(2, 2)
basic.pause(500)
})
Turns the built-in LED on and off repeatedly.
Button A Pressed Message
input.onButtonPressed(Button.A, function () {
basic.showString("Button A!")
})
Displays a message when Button A is pressed.
Count from 1 to 5
for (let i = 1; i <= 5; i++) {
basic.showNumber(i)
basic.pause(500)
}
Counts numbers from 1 to 5 on the LED display.
Display Random Number
basic.showNumber(Math.randomRange(1, 10))
Shows a random number between 1 and 10 on the LED display.
Tilt Detection
basic.forever(function () {
if (input.isGesture(Gesture.TiltLeft)) {
basic.showString("Left")
} else if (input.isGesture(Gesture.TiltRight)) {
basic.showString("Right")
}
})
Displays a message when the micro:bit is tilted left or right.
Show Multiple Icons
basic.showIcon(IconNames.Happy)
basic.pause(500)
basic.showIcon(IconNames.Sad)
basic.pause(500)
basic.showIcon(IconNames.Heart)
Displays a sequence of icons on the LED display.
Temperature Display
basic.showNumber(input.temperature())
Displays the current temperature measured by the micro:bit.
Frequently Asked Questions about Makecode
What is Makecode?
Microsoft MakeCode is a block- and text-based coding platform for creating interactive programs, games, and hardware projects using microcontrollers like micro:bit, Circuit Playground Express, and more.
What are the primary use cases for Makecode?
Teaching coding and computational thinking. Creating microcontroller-based projects. Prototyping simple games and simulations. Interactive electronics with sensors and LEDs. STEM workshops, classrooms, and maker labs
What are the strengths of Makecode?
Beginner-friendly with block interface. Supports transition to text-based coding. Immediate visual feedback with simulator. Strong integration with hardware and sensors. Extensive tutorials and examples for education
What are the limitations of Makecode?
Limited advanced programming features. Not suitable for professional software development. Simulator may not perfectly match hardware behavior. Large projects can become hard to manage. Dependent on browser or MakeCode app for editing
How can I practice Makecode typing speed?
CodeSpeedTest offers 10+ real Makecode code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.