Arduino Helpers
master
Utility library for Arduino
|
This is an example of the AnalogMultiplex class. It prints the states of all 16 switches connected to a multiplexers to the serial monitor.
Optionally you can connect the enable pin as well, this is useful if you want to use multiple multiplexers with the same address lines and the same analog input. Otherwise, just connect the enable pin to ground.
If you are using a 3-bit multiplexer, like the CD74HC4051, you can uncomment the code specific to this multiplexer, and use only three address pins.
Connect a switch or push button between each input pin of the multiplexer and ground. A pull-up resistor is not necessary, because we'll use the internal one.
Open the serial monitor (CTRL+SHIFT+M) or the serial plotter (CTRL+SHIFT+L), and press some buttons, you should see all 16 signals printed or plotted.
Written by Pieter P, 2019-08-08
https://github.com/tttapa/Arduino-Helpers