Skip to content

Instantly share code, notes, and snippets.

@ndomx
Created July 16, 2022 22:33
Show Gist options
  • Save ndomx/d7da93f5082761a77c69bf551d2e9b1b to your computer and use it in GitHub Desktop.
Save ndomx/d7da93f5082761a77c69bf551d2e9b1b to your computer and use it in GitHub Desktop.
GPIO toggle in AVR8 native code
/**
* Toggle GPIO port PB1 (Arduino port 9)
*
* Note: This code only works with
* AVR 8-bit family micro-controllers
*/
#include <avr/io.h>
int main(void)
{
// Set port as output
DDRB |= (1 << PB1);
while (1)
{
// Toggle output
PINB |= (1 << PB1);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment