Simba
7.0.1
  • Installation
  • User Guide
  • Developer Guide
  • Boards
  • Examples
    • Analog Read
    • Analog Write
    • Blink
    • Filesystem
    • Hello World
    • HTTP Client
    • Ping
    • Queue
    • Shell
    • Timer
  • Library Reference
Simba
  • Docs »
  • Examples »
  • Blink
  • Edit on GitHub

Blink¶

About¶

Turn a LED on and off periodically with a one second interval.

Source code¶

/**
 * @file main.c
 * @version 7.0.0
 *
 * @section License
 * Copyright (C) 2015-2016, Erik Moqvist
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * This file is part of the Simba project.
 */

#include "simba.h"

int main()
{
    struct pin_driver_t led;

    /* Start the system. */
    sys_start();

    /* Initialize the LED pin as output and set its value to 1. */
    pin_init(&led, &pin_led_dev, PIN_OUTPUT);
    pin_write(&led, 1);

    while (1) {
        /* Wait half a second. */
        thrd_sleep_us(500000);

        /* Toggle the LED on/off. */
        pin_toggle(&led);
    }

    return (0);
}

The source code can also be found on Github in the examples/blink folder.

Build and run¶

Build and upload the application.

$ cd examples/blink
$ make -s BOARD=<board> upload
Next Previous

© Copyright 2015-2016, Erik Moqvist. Revision f7ebbd8c.

Built with Sphinx using a theme provided by Read the Docs.