U23 2007/Evil Solutions/neu.c

From C4 Wiki
< U23 2007‎ | Evil Solutions
Revision as of 17:38, 7 June 2007 by 87.79.236.180 (talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

#include <avr/io.h>

	
void delay(uint8_t);
int main(void){

	/*
	 * Pin 1: Clock
	 * Pin 2: Shift / Load
	 * Pin 3: Data
	 */
	DDRA = 0xFB;
	DDRC = 0xFF;
	PORTA = 0xFB;

	uint8_t aussen;
	uint8_t wert;

	while(1) {
		wert = 0x00;
		PORTA = 0x00;
		delay(1);
		PORTA = 0x02;
		delay(1);

		if (PORTA & ~(0xFB)){ // DATA ist gesetzt
			wert++;
		}
		wert <<= 1;

		for (aussen = 0; aussen < 3 ; aussen++) {
			PORTA = 0x03;
			delay(1);
			if (PORTA & ~(0xFB)){ // DATA ist gesetzt
				wert++;
			}
			wert <<= 1;
			PORTA = 0x02;
			delay(1);
		}

		PORTC = wert;

	}

	return 0;
}


/*
 * 01 , 02, 04, 08
 */
void delay(uint8_t adelay){

	uint16_t a;
	uint16_t b;

	for (a=0; a < adelay; a++)
		for (b=0; b < 0xFF; b++){
			PORTB = 0x00;
			/*nix*/
		}
}