Question: I have a use-case where I need to control 4+ sonar sensors with a pic 628A microcontroller. The pic is also responsible for controlling a GPS and LCD so pins are scarce. The sonar sensors each have a single signal pin. To operate them, you pulse this pin which produces an ultrasonic chirp and then wait for it to go high again which indicates that an echo was detected. The time between the initial pulse and the response pulse corresponds to the time of flight of the chirp.

I would like to be able to multiplex all of the sonar sensors onto a single bus, but am not sure how to accomplish this. I would like to use only basic components if possible (not specialized IC's) because my main purpose of this experiment is to get a better understanding of the basics. Since the signal channel must allow for both input and output, I do not think bipolar transistors will work. I have considered using FET's to multiplex each signal line, but I am very inexperience with this stuff and would appreciate some direction.

Answer: 
What you want is an 8:1 multiplexer/demultiplexer. You can get them as an [IC](http://www.idt.com/products/memory-logic/bus-switch/50v-quickswitch/qs3251-high-speed-cmos-quickswitch-81-muxdemux), but I don't know if that falls under your idea of a "specialized" IC or not. It's the kind of thing you would use in a freshman digital logic class.

If that's not basic enough for you, the block diagram still shows you what you need to build.![mux/demux block diagram](https://i.stack.imgur.com/nU4cb.gif)

The bottom half is your MOSFETs. The top half is called a *decoder* if you want to get that in a single IC. You can also get the inverters and 4-input AND gates as separate ICs, or you can build those from transistors if that tickles your fancy. Depends how hard you want to make it on yourself.
The simplest approach may be to use something like a 74HC4051 along with some sort of counter chip to select among up to seven devices. One could probably use a single processor pin to do everything if the counter was operated by the rising edge on the data wire, though it would probably be a good idea to add a short delay (perhaps using a couple Schmidt-trigger inverters with an RC delay between them) between the data wire and the counter's clock input (to ensure that the data wire is all the way high before the counter advances). To avoid the need for a separate wire to reset or sense the counter state, wire one of the 74HC4051 inputs to a pull-down resistor which is strong enough to overpower the "normal" pull-up on the pin. Repeatedly asserting and releasing the pin would cause the counter to advance enough to select that input; the data wire would then sit low until the PIC actively drove it high.