---
title: "LED: Blinking"
canonical_url: https://developer.repebble.com/pebbleos/docs/samples/drivers/led/
last_updated: 2026-11-24
sdk_version: 4.44
---
# LED: Blinking

Source: https://developer.repebble.com/pebbleos/docs/samples/drivers/led/

This sample blinks the board’s status LED five times, half a second on and half a second off, through the LED class: the same code drives an LED on a GPIO or one channel of an LED controller.

Run:

`pbl samples samples/drivers/led`

Boards:

every board

## Sources

src/main.c

```
#include \<stdio.h\>#include \<pbl/drivers/led.h\>#include \<pbl/kernel/delay.h\>#define BLINKS 5#define PERIOD\_MS 1000int main(void) {int ret;for (int i = 0; i \< BLINKS; i++) {ret = pbl\_led\_set(STATUS\_LED, PBL\_LED\_BRIGHTNESS\_MAX, 0xffffffU);if (ret != 0) {fprintf(stderr, "led: on failed (%d)\n", ret);return ret;}printf("led: on\n");pbl\_sleep\_ms(PERIOD\_MS / 2);ret = pbl\_led\_set(STATUS\_LED, 0U, 0U);if (ret != 0) {fprintf(stderr, "led: off failed (%d)\n", ret);return ret;}printf("led: off\n");pbl\_sleep\_ms(PERIOD\_MS / 2);}printf("led: blinked %d times\n", BLINKS);printf("Sample done\n");return 0;}
```

## Output

```
led: on
led: off
led: blinked 5 times
Sample done
```

Generated from PebbleOS [12b6c531f](https://github.com/coredevices/pebbleos/commit/12b6c531f9e0c2f39fe4e9bb2886314697128f08). This page is maintained in the pebbleos repository: [docs/samples/drivers/led.md](https://github.com/coredevices/pebbleos/blob/12b6c531f9e0c2f39fe4e9bb2886314697128f08/docs/samples/drivers/led.md).
