The I/O expander schematic

At this point, we have all the information that we need to develop a detailed schematic diagram for our project, as follows:

This design is fairly straightforward. First, the pyboard is supplied 5 volts through the USB or VIN pin. The 5-volt power rail is used to power the LEDs and the RobotDyn PCA8574. The pyboard onboard regulator also converts this rail into a 3.3-volt power rail that is used as the pushbutton power supply.

Next, the negative side of the LEDs, the cathode, is connected to the X1, X2, and X3 pins. These pins are associated with an internal timer that allows us to generate a PWM signal on them. When these pins provide a 100% duty cycle, the LEDs will turn off. Providing a 0% duty cycle will turn them on. While this seems backward, it's the result of the hardware components. To switch this around in the hardware, a transistor can be placed between the LED and the pyboard pin, which inverts the signal. This would also allow more current to flow through the LEDs, which would make them brighter, but would also potentially require a current limiting resistor in series with the diode. In order to minimize the hardware, we will resolve this later in the software.

Finally, we have the RobotDyn PCA8574. The PCA8574 is connected to the pyboard through X9 and X10 with the I2C slave address set to its default value of 0x38 (56 decimal). If there were other I2C devices onboard, we could adjust the address as needed. When the pushbutton is released and not pressed, it provides 3.3 volts to the PCA8574 input channel 0, which is read as a high state. We used a 220-ohm resistor, which could be scaled to 1 or 10K to minimize the leakage current, to pull the voltage to ground and show that it is in a pressed state.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.198.49