All pastes #772001 Raw Edit

Mine

public c v1 · immutable
·published 2007-11-13 13:34 UTC
rendered paste body
#include <avr/io.h>#include <avr/interrupt.h>#include <stdint.h>int8_t prevState;SIGNAL(SIG_INTERRUPT0){        uint8_t port = PORTA;        uint8_t pressed = port & ~prevState;        prevState=port;        if(pressed==1)                PORTD ^=(1<<PD6);        //else if(pressed==2)        //      PORTD ^=(1<<PD5);        else if (pressed==0){                PORTD ^=(1<<PD5);        }}int main(void){        GICR=0xC0;        MCUCR=0x01;        sei();        DDRD |= (1<<PD6)|(1<<PD5);        //      DDRA &= ~(1 << DDA0)|~(1<<DDA1)|~(1<<DDA2)|~(1<<DDA3)|~(1<<DDA4)|~(1<<DDA5)|~(1<<DDA6)|~(1<<DDA7);        DDRA = 0x00; //alla pinnar i porta som input riktning        PORTD |= (1 << PD2);        //PORTA |=(1<<PA0)|(1<<PA1)|(1<<PA2)|(1<<PA3)|(1<<PA4)|(1<<PA5)|(1<<PA6)|(1<<PA7);        //PORTA |=(1<<PA0)|(1<<PA1);//      PORTA &=~(1<<PA0)|~(1<<PA1);        PORTA = 0x00; //pullup 0  pa alla pinnar        while (1) {        }        return 0;}