/* ************************************************************************** */
/* */
/* Monoliticke mikropocitace - Priklad 1.1 */
/* */
/* Program zasvieti/zhasne LED na PD5 podla stavu prepinaca na PD2 */
/* */
/* Autor: Richard Balogh <balogh@elf.stuba.sk> */
/* Historia: */
/* 19.2.2006 prva pokusna verzia */
/* Prenositelnost: */
/* */
/* ************************************************************************** */
#include <avr/io.h> // spolu s -mmcu=atmega16 nahra spravny .h subor
// ktory potrebujeme kvoli PORTx, PINx a DDRx
int main (void)
{
DDRD = 0x??; // bin: 1010 0010 1 = out, 0 = in
PORTD = 0x??; // bin: 1x11 110x 1 = LED zhasni, 1 = pull-up ON
do{
if (PIND & 0x??) // bin: PIND & 0000 0100 = sw1 OFF?
PORTD |= 0x??; // bin PORTD + 0010 0000 = nastav PD5, LED OFF
else // t.j. ak sw1 ON:
PORTD &= 0x??; // bin: PORTD & 1101 1111 = vynuluj PD5, LED ON
} while(1); // toto rob stale dokola
return (0); // formalita, nikdy sem neprideme
}