Skip to content

Instantly share code, notes, and snippets.

@vdemay
Created September 7, 2015 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vdemay/516e7dd7075781bbef0b to your computer and use it in GitHub Desktop.
Save vdemay/516e7dd7075781bbef0b to your computer and use it in GitHub Desktop.
#include <asf.h>
static void config_led(void)
{
struct port_config pin_conf;
port_get_config_defaults(&pin_conf);
//BUTTON
pin_conf.direction = PORT_PIN_DIR_INPUT;
pin_conf.input_pull = PORT_PIN_PULL_UP;
port_pin_set_config(BUTTON_0_PIN, &pin_conf);
//LED
pin_conf.direction = PORT_PIN_DIR_OUTPUT;
port_pin_set_config(LED_0_PIN, &pin_conf);
// TURN OFF
port_pin_set_output_level(LED_0_PIN, LED_0_INACTIVE);
}
int main(void)
{
system_init();
config_led();
while(true)
{
bool button_state = port_pin_get_input_level(BUTTON_0_PIN);
port_pin_set_output_level(LED_0_PIN, !button_state);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment