Difference between revisions of "U23 2007/Evil Solutions/neu.c"

From C4 Wiki
Jump to: navigation, search
(New page: #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; ...)
 
 
Line 1: Line 1:
 +
<pre><nowiki>
 +
 
#include <avr/io.h>
 
#include <avr/io.h>
  
Line 62: Line 64:
 
}
 
}
 
}
 
}
 +
 +
</nowiki> </pre>

Latest revision as of 17:38, 7 June 2007


#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*/
		}
}