Put a few doped regions next to each other and you get a valve. Add a third and you get a switch. Let light in or out and you get an eye or a lamp. Almost the entire electronics shelf is the same trick — p against n — wired into different shapes.