1. Home
  2. /
  3. Zephyr-rtos Typing Test
  4. /
  5. Blink LED Task

Blink LED Task - Zephyr-rtos 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 Task — Zephyr-rtos Code

Toggle an LED on a GPIO pin using a Zephyr thread.

#include <zephyr.h>
#include <device.h>
#include <drivers/gpio.h>

#define LED_PIN 2
#define SLEEP_TIME_MS 500

default struct device *led_dev;

void blink_led(void)
{
	while(1) {
		gpio_pin_toggle(led_dev, LED_PIN);
		k_msleep(SLEEP_TIME_MS);
	}
}

void main(void)
{
	led_dev = device_get_binding("GPIO_0");
	gpio_pin_configure(led_dev, LED_PIN, GPIO_OUTPUT);
	blink_led();
}

Zephyr-rtos Language Guide

Zephyr RTOS is a scalable, open-source real-time operating system designed for resource-constrained embedded devices. It provides a small, configurable kernel, drivers, and networking stacks to enable IoT, wearable, and sensor-based applications with predictable timing and low memory footprint.

Primary Use Cases

  • ▸Real-time task scheduling for embedded applications
  • ▸Low-power IoT devices and wearables
  • ▸Sensor data acquisition and processing
  • ▸Networking-enabled devices with MQTT, CoAP, or BLE
  • ▸Industrial automation and edge computing

Notable Features

  • ▸Modular and configurable kernel
  • ▸Support for multiple architectures and boards
  • ▸Extensive device driver library
  • ▸Real-time thread management and synchronization
  • ▸Networking stack including Bluetooth, IPv4/IPv6, and 6LoWPAN

Origin & Creator

Initially developed by Wind River and now governed by the Linux Foundation, Zephyr was created to provide a lightweight, open-source RTOS for embedded devices and IoT applications.

Industrial Note

Critical for embedded developers who require a deterministic, low-memory RTOS for safety-critical, battery-powered, or connected devices, enabling rapid development and robust device behavior.

Quick Explain

  • ▸Zephyr RTOS provides real-time task scheduling and deterministic performance for embedded systems.
  • ▸It supports multi-threading, inter-thread communication, and hardware abstraction.
  • ▸Used in IoT devices, wearables, industrial sensors, and edge computing applications.
  • ▸Offers modular components including networking, file systems, and device drivers.
  • ▸Supports a wide range of architectures and platforms including ARM, RISC-V, x86, and more.

Core Features

  • ▸Preemptive and cooperative multitasking
  • ▸Inter-thread communication (semaphores, queues, pipes)
  • ▸Timers, work queues, and delayed execution
  • ▸Memory management and heap management
  • ▸Hardware abstraction layer for portability

Learning Path

  • ▸Learn embedded C programming
  • ▸Understand real-time OS concepts
  • ▸Explore Zephyr kernel APIs and threading
  • ▸Practice peripheral interfacing and drivers
  • ▸Build complex IoT applications with Zephyr

Practical Examples

  • ▸Blinking LED and reading GPIO buttons
  • ▸Sensor data acquisition and processing in threads
  • ▸BLE-based wearable communication
  • ▸MQTT client sending sensor data to cloud
  • ▸Low-power sleep modes with scheduled wake-ups

Comparisons

  • ▸Zephyr vs FreeRTOS: Zephyr has modular features and POSIX APIs
  • ▸Zephyr vs RIOT OS: Zephyr supports more architectures and enterprise backing
  • ▸Zephyr vs Mbed OS: Zephyr has smaller footprint and strong open-source community
  • ▸Zephyr vs Linux (embedded): Linux heavier, non-deterministic for hard real-time
  • ▸Zephyr vs ThreadX: Zephyr open-source, ThreadX is commercial

Strengths

  • ▸Small memory footprint suitable for constrained devices
  • ▸Highly configurable and modular to optimize resource usage
  • ▸Strong community and open-source ecosystem
  • ▸Supports real-time deterministic behavior
  • ▸Cross-platform portability across multiple MCUs

Limitations

  • ▸Limited to embedded and resource-constrained platforms
  • ▸Complex for beginners without RTOS experience
  • ▸Networking and advanced features require configuration knowledge
  • ▸Debugging multi-threaded real-time applications can be challenging
  • ▸Smaller ecosystem compared to Linux or FreeRTOS in certain areas

When NOT to Use

  • ▸For applications requiring full-fledged OS features
  • ▸If hardware has abundant memory and Linux is preferred
  • ▸When deterministic real-time is not required
  • ▸For extremely simple, single-threaded microcontroller apps
  • ▸If team lacks embedded RTOS expertise

Cheat Sheet

  • ▸K_THREAD_DEFINE(name, stack_size, entry_fn, ...) - define thread
  • ▸k_sleep(ms) - delay thread execution
  • ▸k_sem_init/ k_sem_take/ k_sem_give - semaphore usage
  • ▸k_fifo_put / k_fifo_get - FIFO communication
  • ▸DEVICE_DT_GET(node) - access device from device tree

FAQ

  • ▸Does Zephyr support multiple architectures? -> Yes, including ARM, RISC-V, x86.
  • ▸Can Zephyr be used for battery-powered devices? -> Yes, supports low-power modes.
  • ▸Is Zephyr open-source? -> Yes, governed by the Linux Foundation.
  • ▸Does Zephyr have networking support? -> Yes, includes IPv4/IPv6, BLE, MQTT, CoAP.
  • ▸Is Zephyr suitable for industrial applications? -> Yes, used in safety-critical and IoT devices.

30-Day Skill Plan

  • ▸Week 1: RTOS basics and threading in Zephyr
  • ▸Week 2: GPIO, UART, and sensor integration
  • ▸Week 3: Multi-threaded applications and synchronization
  • ▸Week 4: Networking and IoT protocol integration
  • ▸Week 5: Optimization, debugging, and deployment

Final Summary

  • ▸Zephyr RTOS is a lightweight, real-time OS for embedded and IoT devices.
  • ▸Provides modular kernel, multi-threading, and peripheral support.
  • ▸Supports networking, low-power operation, and cross-platform deployment.
  • ▸Ideal for deterministic and scalable embedded applications.
  • ▸Backed by open-source community with active ecosystem and tooling.

Project Structure

  • ▸Zephyr project directory with source and include files
  • ▸CMakeLists.txt for build configuration
  • ▸prj.conf for kernel and feature settings
  • ▸boards/ directory with board definitions
  • ▸modules/ directory for optional subsystems

Monetization

  • ▸Consulting for embedded IoT systems
  • ▸Custom Zephyr firmware development
  • ▸Training in real-time embedded development
  • ▸Industrial sensor and automation solutions
  • ▸Edge device deployment services

Productivity Tips

  • ▸Reuse existing Zephyr modules and sample apps
  • ▸Leverage device tree for peripheral management
  • ▸Use west for dependency management and builds
  • ▸Enable only necessary kernel features
  • ▸Profile and optimize threads and memory usage

Basic Concepts

  • ▸Thread - basic execution unit with priority and stack
  • ▸Scheduler - manages thread execution order
  • ▸Kernel Objects - semaphores, mutexes, queues for synchronization
  • ▸Device Driver - interface to hardware peripherals
  • ▸Work Queue - deferred task execution mechanism

Official Docs

  • ▸https://www.zephyrproject.org/documentation/
  • ▸Zephyr API and Kernel Guides
  • ▸Board and peripheral support documentation

More Zephyr-rtos Typing Exercises

Periodic Thread ExampleSensor Reading Example

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher