1. Home
  2. /
  3. Mbed-c-cpp-python Typing Test
  4. /
  5. Blink LED (C++)

Blink LED (C++) - Mbed-c-cpp-python Typing CST Test

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
Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
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.

Blink LED (C++) — Mbed-c-cpp-python Code

Toggle an LED on pin LED1 every 500 ms using Mbed C++.

#include "mbed.h"

DigitalOut led(LED1);

int main() {
	while (true) {
		led = !led;
		ThisThread::sleep_for(500ms);
	}
}

Mbed-c-cpp-python Language Guide

MBed is an open-source platform for developing IoT and embedded applications using C, C++, and Python. It provides an OS, hardware abstraction libraries, and development tools to rapidly create, test, and deploy programs on ARM Cortex-M microcontrollers.

Primary Use Cases

  • ▸Develop firmware for ARM Cortex-M microcontrollers using C/C++
  • ▸Rapid prototyping of embedded IoT devices
  • ▸Interfacing with sensors and actuators
  • ▸Running MicroPython scripts for lightweight embedded tasks
  • ▸Deploying secure, connected devices with MBed OS

Notable Features

  • ▸Real-time operating system (RTOS) support
  • ▸MBed libraries for networking, storage, and drivers
  • ▸Hardware abstraction layer for multi-platform support
  • ▸Cloud and IoT integration tools
  • ▸MicroPython support for scripting on microcontrollers

Origin & Creator

Developed by ARM in 2011 to simplify IoT development and standardize embedded software across ARM Cortex-M microcontrollers.

Industrial Note

Extensively used in IoT devices, industrial automation, wearable electronics, robotics, and rapid prototyping of ARM-based microcontrollers.

Quick Explain

  • ▸MBed OS is a real-time operating system for embedded devices, supporting C/C++ and Python (via MicroPython).
  • ▸Provides hardware abstraction for sensors, actuators, and communication interfaces (I2C, SPI, UART, GPIO).
  • ▸MBed Studio and online compiler allow coding, compiling, and flashing firmware to boards.
  • ▸Supports Python for scripting and quick prototyping via MicroPython on supported devices.
  • ▸Widely used for IoT, robotics, wearables, and educational embedded projects.

Core Features

  • ▸RTOS with threading, timers, and event handling
  • ▸Peripheral drivers for GPIO, PWM, ADC, I2C, SPI, UART
  • ▸Networking stack: Ethernet, Wi-Fi, BLE, MQTT
  • ▸Filesystem abstraction and external storage support
  • ▸Secure firmware updates and cryptography APIs

Learning Path

  • ▸Learn basic C/C++ programming
  • ▸Understand MBed OS architecture and API
  • ▸Practice GPIO, UART, I2C, SPI peripherals
  • ▸Advance to RTOS threads, timers, and interrupts
  • ▸Explore IoT integration and MicroPython scripting

Practical Examples

  • ▸Blink an LED and read button input
  • ▸Read temperature from a sensor and log via UART
  • ▸Control a motor with PWM signals
  • ▸Send sensor data to cloud using Wi-Fi/BLE
  • ▸Run MicroPython scripts for quick prototype logic

Comparisons

  • ▸MBed vs Arduino: MBed offers RTOS and ARM Cortex-M support; Arduino simpler for beginners
  • ▸C/C++ vs Python: C/C++ for performance, Python for rapid prototyping
  • ▸MBed vs Raspberry Pi: MBed for microcontrollers, Pi for Linux-based SBCs
  • ▸MBed OS vs FreeRTOS: Both RTOS, MBed OS has ARM ecosystem integration
  • ▸MBed vs STM32Cube: MBed higher-level abstraction, Cube closer to hardware

Strengths

  • ▸Cross-platform portability on ARM Cortex-M devices
  • ▸Rapid prototyping using C/C++ and Python
  • ▸Rich library ecosystem and community support
  • ▸Built-in RTOS and peripheral drivers for fast development
  • ▸Integration with MBed Cloud for IoT devices

Limitations

  • ▸Limited to ARM Cortex-M microcontrollers
  • ▸Python (MicroPython) support is slower than native C/C++
  • ▸Resource-constrained devices may limit complex applications
  • ▸Debugging can be challenging on certain hardware
  • ▸Requires understanding of embedded programming and real-time concepts

When NOT to Use

  • ▸For non-ARM microcontrollers or SBCs
  • ▸For purely desktop or server applications
  • ▸When low-level bare-metal control is required
  • ▸For very constrained memory microcontrollers (<16KB flash)
  • ▸When Python-only is sufficient without real-time tasks

Cheat Sheet

  • ▸DigitalOut pin(LED1) - Control digital output
  • ▸AnalogIn sensor(A0) - Read analog input
  • ▸ThisThread::sleep_for(100ms) - Delay in RTOS thread
  • ▸Thread t(osPriorityNormal) - Create a new thread
  • ▸I2C i2c(SDA, SCL) - I2C communication setup

FAQ

  • ▸Can I use MBed with non-ARM boards? -> Generally no, MBed OS targets ARM Cortex-M.
  • ▸Is Python as fast as C/C++ on MBed? -> No, MicroPython is slower but good for prototyping.
  • ▸Does MBed support Wi-Fi and BLE? -> Yes, via network libraries and drivers.
  • ▸Can I run multiple threads? -> Yes, MBed OS supports RTOS threading.
  • ▸Do I need MBed Studio? -> Optional, you can use online compiler or other IDEs.

30-Day Skill Plan

  • ▸Week 1: Blink LEDs, read buttons and sensors
  • ▸Week 2: Control actuators and communication interfaces
  • ▸Week 3: Implement RTOS tasks and scheduling
  • ▸Week 4: Build small IoT projects with cloud connectivity
  • ▸Week 5: Optimize code, implement MicroPython prototypes

Final Summary

  • ▸MBed enables C, C++, and Python development for ARM Cortex-M microcontrollers.
  • ▸Supports RTOS, hardware abstraction, and rapid prototyping.
  • ▸Widely used for IoT, robotics, wearable electronics, and embedded systems.
  • ▸MicroPython allows scripting for quick prototypes.
  • ▸Essential for developers building secure, connected, and real-time embedded applications.

Project Structure

  • ▸Application source files (.cpp/.c or .py)
  • ▸MBed OS library files
  • ▸Header files (.h) for drivers and APIs
  • ▸Configuration files (mbed_app.json, targets.json)
  • ▸Optional scripts for deployment or testing

Monetization

  • ▸IoT device development and prototyping
  • ▸Custom embedded solutions for industrial clients
  • ▸Robotics and automation firmware development
  • ▸Consulting for MBed-based product development
  • ▸Training workshops for MBed and embedded programming

Productivity Tips

  • ▸Use MBed libraries for standard peripherals
  • ▸Leverage MicroPython for rapid prototyping
  • ▸Modularize code for easier maintenance
  • ▸Automate flashing and testing via CLI
  • ▸Document projects for reproducibility

Basic Concepts

  • ▸Pins - digital and analog I/O
  • ▸Timers - for scheduling and delays
  • ▸Threads - concurrent execution using RTOS
  • ▸Peripherals - sensors, actuators, communication interfaces
  • ▸Scripts - MicroPython programs for embedded tasks

Official Docs

  • ▸https://os.mbed.com/docs/mbed-os/latest/
  • ▸https://os.mbed.com/
  • ▸https://os.mbed.com/handbook/
  • ▸https://os.mbed.com/teams/

More Mbed-c-cpp-python Typing Exercises

Read Analog Sensor (C++)Control Servo Motor (Python / MicroPython)

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher