/**********************************************************************************************/ // Include Dateien /**********************************************************************************************/ #include // Für den PIC - wird autom. erkannt #include "delays.h" // Für die Warteschleife /**********************************************************************************************/ // Konfiguration /**********************************************************************************************/ #pragma config FOSC = HS #pragma config PWRT = ON #pragma config BOR = OFF #pragma config WDT = OFF #pragma config LVP = OFF #pragma config PBADEN = OFF #pragma config VREGEN = OFF #pragma config MCLRE = ON /**********************************************************************************************/ // Deklarationen /**********************************************************************************************/ unsigned char alfa = 224; unsigned char zero = 0; /**********************************************************************************************/ // Unterprogramme /**********************************************************************************************/ void LED(void) // Unterprogramm (Funktion) "LED" { PORTC = 0x10; // Setzte PORTB,0 Delay10KTCYx(1000); // Verzögerung --> Damit 1 Tasterdruck nicht ein/aus schaltet while(PORTB == alfa) // Verharre hier solange, wie PORTA = 0 ist { } return; // Danach kehre wieder zurück (sobald Bedingung erfüllt ist) } /**********************************************************************************************/ // Hauptprogramm /**********************************************************************************************/ void main(void) // Anfang { TRISA = 0x00; // PORTA ist als Output konfiguriert TRISB = 0xE0; // PORTB,5,6,7 ist als Input konfiguriert TRISC = 0x00; // PORTB ist als Output konfiguriert if(alfa == PORTB) // Wenn PORTA,0 gleich 1 ist, dann.. { LED(); // Ruf das Unterprogramm (Funk) "LED" auf } PORTC = 0x00; // Lösche PORTB,0 return; // Und von vorne } /**********************************************************************************************/ // Ende des Programms /**********************************************************************************************/