Hallo PicNick,

ich bin gespannt...

Es sind drei Dateien... Ein Winziges Programm:

die main.c:
Code:
/************************************************************************************/
/*	Projektname		-=>	ATMega32 Versuche      										*/
/*	Programmversion	-=>	V0.1														*/
/*	Mikrocontroller	-=>	ATMega32													*/
/* 	Letzte Änderung	-=>	12.04.2008 													*/
/************************************************************************************/



//  -=> Defines & Includes <=-
	
	//  -=> Defines <=-
		#define F_CPU 1000000
		
		
	//  -=> AVR Includes <=-
		#include <avr/io.h>
		#include <util/delay.h>
		
	//  -=> Programmheaders <=-
		
		
	//  -=> Programmfiles <=-
		#include <led.c>
		#include <dip.c>
	
	
//  -=> Intrrupts <=-
	
	
//  -=> Hauptfunktion <=-
	
	int main (void){
		
		//  -=> Initialisieren <=-
			LED_INIT();
			DIP_INIT();
			
		//  -=> Hauptschleife <=-
		while(1){
			
			if( DIP1() ){ 
				//Erster Wartezyklus
				LED1(1);
				LED2(0);
				_delay_ms(500);
				
				//Zweiter Wartezyklus
				LED1(0);
				LED2(1);
				_delay_ms(500);
				
			}else{
				//Erster Wartezyklus
				LED1(1);
				LED2(0);
				_delay_ms(50);
				
				//Zweiter Wartezyklus
				LED1(0);
				LED2(1);
				_delay_ms(50);
			}
			
		}
		return 0;
	}
	
	
/************************************************************************************/
Die led.c:
Code:
//LED-TREIBER


//LED INIT
void LED_INIT(void) {
	DDRA = (1<<PA5) | (1<<PA0);
}

//LED1 - ON/OFF
void LED1( unsigned int set ) {
	
	if(set) {
		PORTA |=   (1<<PA0);
	}else{
		PORTA &= ~ (1<<PA0);
	}	
}

//LED2 - ON/OFF
void LED2( unsigned int set ) {
	
	if(set) {
		PORTA |=   (1<<PA5);
	}else{
		PORTA &= ~ (1<<PA5);
	}	
}
Die dip.c:
Code:
//DIP

//INIT
void DIP_INIT(void) {
	DDRB  &= ~(1<<PB0);		//PINB0 als Eingang
	PORTB |=  (1<<PB0);		//PINB0 10K PullUp aktivieren
}

uint8_t DIP1( void ) {
	if( PINB & (1<<PB0) ){		//Wenn PINB0 = 1 (5V)
		return 0;				//Verlasse Funktion mit 0 (AUS)
	}else{						//Ansonsten 
		return 1;				//Verlasse Funktion mit 1 (EIN)
	}
	
}