Skip to content

Instantly share code, notes, and snippets.

@pearlchen
Last active August 29, 2015 14:25
Show Gist options
  • Save pearlchen/f6ebf4b55e3468bee9a4 to your computer and use it in GitHub Desktop.
Save pearlchen/f6ebf4b55e3468bee9a4 to your computer and use it in GitHub Desktop.
2 different versions of the bare minimum code required to blink an LED on pin 13 (aka J17-14) using an Intel Edison and C++.
#include "mraa.hpp"
int main()
{
// set GPIO digital pin "13" to be an output
mraa_gpio_context d_pin = mraa_gpio_init_raw(128);
mraa_gpio_dir(d_pin, MRAA_GPIO_OUT_HIGH);
// loop forever toggling the on board LED every second
for (;;) {
mraa_gpio_write(d_pin, 1);
sleep(1);
mraa_gpio_write(d_pin, 0);
sleep(1);
}
return MRAA_SUCCESS;
}
#include "mraa.hpp"
int main()
{
// set GPIO digital pin "13" to be an output
mraa::Gpio* d_pin = NULL;
d_pin = new mraa::Gpio(13, true, false);
d_pin->dir(mraa::DIR_OUT);
// loop forever toggling the on board LED every second
for (;;) {
d_pin->write(1);
sleep(1);
d_pin->write(0);
sleep(1);
}
return MRAA_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment