Programming the PIC Microcontroller with MBasic

We're going to look at two communications protocols, "1-wire" and "three-wire" (also known as SPI Serial Peripheral Interface) for serial data exchange between a PIC and external sensors. We'll look at these protocols in the context of two specific devices, the DS18B20 12-bit temperature sensor and the DS1302 real time clock, but we'll see SPI again in later chapters. (By the way, don't confuse Dallas Semiconductor's DS18B_20 sensor with its similar, cheaper, DS18S20 device. The DS18S20 is also a 1-wire temperature sensor, but with 9-bit resolution, yielding 0.5 C steps.)
In order to keep our discussion of manageable length, we'll briefly mention that these devices are but two examples from the world of sensors. One form or another of electronic sensor can measure almost any physical parameter of interest, directly or indirectly. Historically, sensors used an analog change in an electrically measurable parameter resistance, capacitance or voltage being the most common to measure a change in an underlying parameter, such as temperature, humidity, pressure, acceleration, or light intensity. Since the sensor output is analog, the resulting value must be read with an analog instrument, or converted to a digital value with an analog to digital converter.
Pure analog sensors are still widely used, but have been augmented with a built-in digital conversion, so the output can be directly read by a microcontroller, even though the microcontroller doesn't have a built-in ADC. (Don't be fooled by the digital output, however, as in almost every case the underlying physical sensor process remains analog.)