1. Home
  2. /
  3. Mbed-cpp
  4. /
  5. Mbed C++ PWM LED Brightness

Mbed C++ PWM LED Brightness - Mbed-cpp Typing CST Test

Loading…

Mbed C++ PWM LED Brightness — Mbed-cpp Code

Adjusts LED brightness using PWM output.

#include "mbed.h"

PwmOut led(LED1);
int brightness = 0;

void updateLED() {
	led.write(brightness / 100.0);
	printf("LED Brightness: %d\n", brightness);
}

void increaseBrightness() {
	brightness += 20;
	if(brightness > 100) brightness = 0;
	updateLED();
}

int main() {
	updateLED();
	increaseBrightness();
	increaseBrightness();
}

Mbed-cpp Language Guide

Mbed OS (mbed-cpp) is an open-source embedded operating system and C++ framework designed for ARM Cortex-M microcontrollers. It provides a full-featured platform for building IoT devices, supporting real-time operating system capabilities, peripheral access, and connectivity.

Primary Use Cases

  • ▸Professional IoT and embedded device development
  • ▸Real-time applications with RTOS support
  • ▸Networking and connected devices (Wi-Fi, BLE, LoRa, Ethernet)
  • ▸Sensor and actuator control for robotics and automation
  • ▸Prototyping and production-level embedded systems

Notable Features

  • ▸RTOS with multi-threading, timers, and events
  • ▸Hardware abstraction layer for peripherals
  • ▸Connectivity stacks for Wi-Fi, BLE, Ethernet, LoRa, and cellular
  • ▸Power management and low-power modes
  • ▸Extensive C++ library ecosystem for embedded development

Origin & Creator

Developed by ARM Ltd. in 2009 to create a unified C++ platform for ARM Cortex-M microcontrollers and IoT devices.

Industrial Note

Mbed OS is widely used in industrial IoT, connected devices, wearable electronics, and embedded prototyping where professional-grade C++ performance and RTOS features are required.

More Mbed-cpp Typing Exercises

Mbed C++ Button Press CounterMbed C++ LED BlinkMbed C++ Temperature MonitorMbed C++ Relay ToggleMbed C++ Buzzer ToggleMbed C++ Fan Speed ControlMbed C++ Dual LED ToggleMbed C++ Humidity AlertMbed C++ LED Blink Pattern

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher