// CD74HC4067
// 16-Channel Analog Multiplexer
// https://www.ti.com/lit/ds/symlink/cd74hc4067.pdf
#include <Adafruit_NeoPixel.h>
#define COM 12
#define NP_PIN 4
#define NUMPIXELS 16
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, NP_PIN, NEO_GRB + NEO_KHZ800);
const uint8_t controlPins[] = { 23, 22, 21, 19 };
int readMux(int channel)
{
for(int i = 0; i < 4; i ++)
{
digitalWrite(controlPins[i], channel >> i & 1);
}
delay(10);
return digitalRead(COM);
}
void setup()
{
pinMode(COM, INPUT);
for (int i = 0; i < 4; ++i)
{
pinMode(controlPins[i], OUTPUT);
}
pixels.begin();
}
void loop()
{
pixels.clear();
for(int i = 0; i < 16; ++i)
{
if (readMux(i))
{
pixels.setPixelColor(i, pixels.Color(0, 150, 0));
}
}
pixels.show();
}