Skip to content

Instantly share code, notes, and snippets.

@chuckwagoncomputing
Created January 28, 2014 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuckwagoncomputing/8662091 to your computer and use it in GitHub Desktop.
Save chuckwagoncomputing/8662091 to your computer and use it in GitHub Desktop.
First attempt at AVR C programming. (Attiny85)
#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