/*
* main.c
*
* Created on: Apr 24, 2014
* Author: hendri
*/
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
ISR(PCINT0_vect)
{
if (!(PINB & (1<<4))) {
PORTB|=(1<<7);
_delay_ms(1000);
PORTB&=~(1<<7);
}
}
int main (void)
{
DDRA=0xff;
DDRB |=(1<<PB7);// LED output enable
PORTB|=(1<<PB4); // pint PCINT4 pullup
PCMSK0 |= (1<<PCINT4); // enable interrupt
PCICR |= _BV(PCIE0);
// push button 2
PORTB|=(1<<PB5); // pint PCINT5 pullup
PCMSK0 |= (1<<PCINT5); // enable interrupt
PCICR |= _BV(PCIE0);
sei();
while (1){
PORTA=0x00;
for (unsigned char i=0;i<8;i++)
{
PORTA = ~(1<<i);
_delay_ms(500);
}
}
}