Created
August 26, 2016 15:41
-
-
Save pepijndevos/76fbf714e11569f688c19bf070f51435 to your computer and use it in GitHub Desktop.
Attiny25 binary counter
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
#include <avr/io.h> | |
int main(void) { | |
PORTB = 0; | |
DDRB = 0b1111; | |
uint8_t counter = 0; | |
uint8_t input=0; | |
uint8_t previous_input=0; | |
while(1) { | |
input = PINB & (1<<PINB4); | |
if ((input == 0) && (previous_input != input)) { | |
PORTB = (counter>>1) & 0b1111; | |
counter++; | |
} | |
previous_input = input; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment