Skip to content

Instantly share code, notes, and snippets.

@vdemay vdemay/led_toggle.c
Created Sep 7, 2015

Embed
What would you like to do?
#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
You can’t perform that action at this time.