Skip to content

Instantly share code, notes, and snippets.

@navin-bhaskar
Created November 13, 2015 14:20
Show Gist options
  • Select an option

  • Save navin-bhaskar/d487b6b47dc49eba3e6d to your computer and use it in GitHub Desktop.

Select an option

Save navin-bhaskar/d487b6b47dc49eba3e6d to your computer and use it in GitHub Desktop.
/**
*
* This is a 'c' program that demos the usage of the mraa library
* to blink an LED connected to port D5 on Intel Edison/Galileo
*
* setup:
* The LED is connected to port D5
*
* Compilation:
* gcc -o blink blinky.c -lmraa
*
* Demo:
* Run the application
* ./blinky
* You should see the LED blink
*
* You can exit this demo by hitting ctrl+c
*
*
*/
#include <mraa.h>
#define LED_PIN 5 /**< The pin where the LED is connected */
int main(void)
{
mraa_gpio_context ledPin;
/* Step1: Init the mraa subsystem */
mraa_init();
/* Step2: Set the ledPin as port D5 */
ledPin = mraa_gpio_init(LED_PIN);
/* Step3: Set the said pin as output */
mraa_gpio_dir(ledPin, MRAA_GPIO_OUT);
while(1)
{
/* Step4: Set the desired voltage level at the pin */
mraa_gpio_write(ledPin, 1);
sleep(1);
mraa_gpio_write(ledPin, 0);
sleep(1);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment