Improved Logic Gates.

Maybe

digitalWrite(0, !digitalRead(3));

For NOT.

I'd also think about using direct port manipulation to make these "gates" faster.

EDIT: f'example, an AND function

switch (PINB & 3) {		// assumes inputs on bits 0 and 1

	case 0:
	case 1:
	case 2:
		PORTB &= ~(1 << 2);	// assumes outputs on bit 2
		break;
		
	case 3:
		PORTB |= (1 << 2);
	
}

I haven't checked which bits are which, just an example.


Rob