Digital electronics
Before we start interfacing the Pi to any electronics, we will first take a look at some of the fundamentals of digital electronics.
Logic in digital electronics is composed of two states: high and low. Typically, low is represented by the signal being close to the ground (0V) and high is represented by being close to a reference voltage (usually, the operating voltage of the logic device). In the case of the Raspberry Pi, it is 3.3V.
Note
Be sure that any device that you connect to the Raspberry Pi via the GPIO port can operate at 3.3V.
The point at which a signal changes between these two states is known as an edge. This can either be rising or falling depending on the direction of the state change, as shown in the following diagram:
Another concept we will see later in this chapter is Pulse Width Modulation (PWM). This is the concept of simulating an analog signal (a constant signal at a voltage between the high and the low levels) by creating a digital signal and varying...