Created
January 28, 2014 04:05
-
-
Save chuckwagoncomputing/8662091 to your computer and use it in GitHub Desktop.
First attempt at AVR C programming. (Attiny85)
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/sleep.h> | |
#include <avr/interrupt.h> | |
volatile int pinOutState; | |
ISR(PCINT0_vect){ | |
if (pinOutState == 0){ | |
PORTB = (1 << PB1); | |
pinOutState = 1; | |
} | |
else if (pinOutState == 1){ | |
PORTB = (0 << PB1); | |
pinOutState = 0; | |
} | |
} | |
int main(void){ | |
DDRB |= (1 << PB1); | |
DDRB &= ~(0 << PB0); | |
GIMSK |= (1 << PCIE); | |
PCMSK |= (1 << PCINT0); | |
MCUCR |= (1 << ISC00) | (1 << ISC01); | |
sei(); | |
sleep_bod_disable(); | |
sleep_enable(); | |
while(1){ | |
sleep_cpu(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment