Created
July 16, 2022 22:33
-
-
Save ndomx/d7da93f5082761a77c69bf551d2e9b1b to your computer and use it in GitHub Desktop.
GPIO toggle in AVR8 native code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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