quarta-feira, 8 de setembro de 2010

Botão e led com atmega8 - AVR studio

//
// acender led com botao
//
//Autor : aguivone
//data : 17/08/2010
//descrição : não necessária
//
//
////////////////////////////////////////////////////////////////////////////////////////////////////////

#include

////////////////////////funçoes usadas ////////////////////////////////////////////////////////////

void Inicializa_chip(void)//inicializa portas
{
PORTB = (1<0)
{
count--;
}
}

/////////////////////////////////////////////função principal//////////////////////////////////////////////////

int main(void)
{
Inicializa_chip();
PORTD=0XFF;
while(1)
{
if((PINB & 4)==0)//faz uma logica and com o portb
{
while((PINB & 4)==0)
{
PORTB |= 0x08;
Delay(300);
PORTB &= 0x00;
Delay(300);
}
PORTB &= 0x01;
}
PORTB ^= 0x01;///usando ou exclusivo a inversão é mais rapido
Delay(1000);
PORTD = ~ PORTD;//inverte PORTD
}
}

///////////////////////////////////////////////////////////////////////////////////////////////////

Nenhum comentário :

Postar um comentário

olá,digite aqui seu comentário!