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