Skip to main content
CodeSpeedTest
Languages
Start TypingJump into a test — pick any languageAdaptive TrainingUnlock chars as you master themPractice DrillsFocused sessions targeting weak spotsDaily ChallengesNew coding challenges every dayRace ModeCompete against others in real timeAI OpponentRace against an AI at your WPM levelTournamentsLive coding speed tournamentsArcade GamesZType, Overkill Survival, Glyphica & moreGamificationXP, coins, badges & quests
LeaderboardGlobal rankings for every languageCertificatesEarn verifiable Bronze / Silver / Gold certsActivityDaily streaks & historical analyticsProfileYour stats, badges & achievements
Browse Languages500+ languages with real code examplesBlogTips, guides & deep divesFree ToolsWPM calculator, typing speed report & moreFAQCommon questions answeredGetting StartedNew to CodeSpeedTest?AboutOur story & missionSupportGet help — Pro users get priorityContactGet in touch with the team
Pricing
  1. Home
  2. /
  3. Learn
  4. /
  5. Makecode

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.

View all 10 Makecode code examples →
Hello World in MakeCode (JavaScript view)Scroll Text on micro:bitDisplay a Heart IconBlink an LEDButton A Pressed MessageCount from 1 to 5Display Random NumberTilt DetectionShow Multiple IconsTemperature Display

Learn MAKECODE with Real Code Examples

Explain

Visual block-based editor with drag-and-drop coding for beginners.

Text-based JavaScript or Python mode for advanced users.

Supports interactive hardware, LED displays, sensors, and input devices.

Real-time simulator to test code without hardware.

Used for teaching coding, electronics, and STEM concepts in classrooms and at home.

Core Features

Blocks - visual programming elements

JavaScript/Python - text coding alternative

Simulator - test programs virtually

Hardware integration - micro:bit, Circuit Playground Express, LEGO, etc.

Extensions - add new sensors, games, or devices

Basic Concepts Overview

Block - visual code unit representing actions or logic

Loop - repeat instructions continuously

Event - triggered by input (button, sensor, or time)

Variable - stores data for program state

Simulator - tests code virtually before deploying

Project Structure

main.ts or main.py - main code file

project.json - project metadata

assets/ - images, sounds, or sprites

extensions/ - optional libraries for hardware

README.md - documentation or notes

Building Workflow

Select project template for target device

Use blocks or text to write code

Test in simulator and debug

Connect hardware and deploy program

Iterate to improve functionality or interactivity

Difficulty Use Cases

Beginner: simple LED patterns

Intermediate: sensor-based interactions

Advanced: multi-sensor games or robotics

Expert: integrating multiple hardware extensions

Educator: designing STEM curriculum projects

Comparisons

MakeCode vs Scratch: hardware-focused vs general animation/game

MakeCode vs Processing.py: block/hardware vs creative coding desktop

MakeCode vs Arduino IDE: beginner-friendly vs text-heavy hardware programming

MakeCode vs Tinkercad CodeBlocks: more hardware options vs 3D modeling integration

MakeCode vs PXT: same Microsoft platform, different UI versions

Installation Setup

Access MakeCode via https://makecode.com/

Choose target device (micro:bit, Circuit Playground, etc.)

Use web IDE or install offline app

Create new project using blocks or text

Connect hardware to test code or use simulator

Architecture

Web-based IDE with block and text editor

Simulator runs in browser for real-time testing

Hardware runtime executes code on microcontrollers

Extension libraries provide additional devices and functions

Project files saved as JSON or downloadable hex files for hardware

Performance Notes

Block programs are fast for microcontrollers

Simulator may slow for complex visuals

Memory on hardware is limited, optimize usage

Use loops efficiently to conserve CPU cycles

Sensor polling can affect performance if frequent

Security Notes

Run code only from trusted sources

Do not download unverified hex files

Avoid connecting to unsafe hardware devices

Simulator is safe in browser environment

Back up project files regularly

Practical Examples

Blinking LED with button input

Temperature-sensor logging

Simple micro:bit game (rock-paper-scissors)

Animated display on LED matrix

Robotics control with multiple motors

Troubleshooting

Check hardware connections

Verify correct device selected in IDE

Use simulator to isolate issues

Ensure proper extension libraries are loaded

Restart browser or app if simulator crashes

Testing Guide

Use simulator extensively before deploying

Test events for correct triggering

Check variable values and logic

Iterate in small steps to avoid large bugs

Verify program behavior on actual hardware

Deployment Options

Download .hex file for micro:bit

Export to Circuit Playground Express

Use MakeCode Arcade for web-based games

Share projects via link or GitHub

Embed in educational workshops or curriculum

Tools Ecosystem

Web-based MakeCode IDE

Offline MakeCode apps

Hardware kits (micro:bit, Adafruit Circuit Playground, LEGO)

Extensions for sensors, displays, and motors

Community project gallery and examples

Integrations

Microcontroller hardware for hands-on projects

Classroom STEM kits

Third-party extensions for robotics or IoT

Simulation for offline testing

Export to GitHub or shareable hex files

Code Sample Descriptions

1

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.

Let’s Try →
2

Scroll Text on micro:bit

basic.showString("Welcome!")

Scrolls a custom message on the micro:bit LED display.

Let’s Try →
3

Display a Heart Icon

basic.showIcon(IconNames.Heart)

Shows a heart icon on the micro:bit LED display.

Let’s Try →
4

Blink an LED

basic.forever(function () {
    led.toggle(2, 2)
    basic.pause(500)
})

Turns the built-in LED on and off repeatedly.

Let’s Try →
5

Button A Pressed Message

input.onButtonPressed(Button.A, function () {
    basic.showString("Button A!")
})

Displays a message when Button A is pressed.

Let’s Try →
6

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.

Let’s Try →
7

Display Random Number

basic.showNumber(Math.randomRange(1, 10))

Shows a random number between 1 and 10 on the LED display.

Let’s Try →
8

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.

Let’s Try →
9

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.

Let’s Try →
10

Temperature Display

basic.showNumber(input.temperature())

Displays the current temperature measured by the micro:bit.

Let’s Try →

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.

Learn Other Programming Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypherGremlinPartiqlHaskellElixirFsharpView all languages →
CodeSpeedTest

Improve your coding speed, code accuracy, and programming syntax WPM with practice sessions across 500+ programming languages.

Quick Links

HomeAboutFeaturesGetting StartedLanguages

Legal & Support

Pro ⚡ PricingContactPrivacy PolicyTerms of Service

Connect

CodeSpeedTest on GitHubCodeSpeedTest on TwitterEmail CodeSpeedTest

© 2026 CodeSpeedTest. All rights reserved.