Blink¶
About¶
Turn a LED on and off periodically with a one second interval.
Source code¶
/**
* @file main.c
*
* @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_ms(500);
/* Toggle the LED on/off. */
pin_toggle(&led);
}
return (0);
}
The source code can also be found on Github in the examples/blink folder.