#include sbit LS1 = P0^0; // Deklaration der Lichtschranke 1 sbit LS2 = P0^1; // Deklaration der Lichtschranke 2 void main( void ) { unsigned char ucValue = 0; // Variable "ucValue" auf Null setzen P2M1 = 0x00; // Port 2 als quasi-bidirektional P2M2 = 0x00; P2 = ~ucValue; // Zuweisung Variable als Komplement while ( 1 ) // Endlosschleife { if (( LS1 == 0 ) && ( LS2 == 0 )) // Abfage der Lichtschranken { ucValue = ucValue -1; // zähle hoch P2 = ucValue; // gibt Variable an Port 2 aus while ( LS2 == 0 ) // warten, solange LS2 noch meldet { ; } } } }