If you have in your constructor this:
CD74HC4067::channelSelects[16][4] = ...
then you are trying to assign something into the element at position [16][4]
. Thats why it's telling you
cannot convert '' to 'uint8_t {aka
unsigned char}'
Anyway - you don't even need that second dimension. You can use binary representation like 0b00001000
...
And if you'll think about previous line, you don't even need any array, you can do it with simple counter value and getting its bits.
However if you want to rely on this array, the constructor should look like:
CD74HC4067::CD74HC4067() :
channelSelects {
{ 0,0,0,0 }, // channel 0
{ 1,0,0,0 }, // channel 1
{ 0,1,0,0 }, // channel 2
{ 1,1,0,0 }, // channel 3
{ 0,0,1,0 }, // channel 4
{ 1,0,1,0 }, // channel 5
{ 0,1,1,0 }, // channel 6
{ 1,1,1,0 }, // channel 7
{ 0,0,0,1 }, // channel 8
{ 1,0,0,1 }, // channel 9
{ 0,1,0,1 }, // channel 10
{ 1,1,0,1 }, // channel 11
{ 0,0,1,1 }, // channel 12
{ 1,0,1,1 }, // channel 13
{ 0,1,1,1 }, // channel 14
{ 1,1,1,1 } // channel 15
}
{
// constructor code
}
(maybe one more {} enclosure, I'm not sure right now exactly)
EDIT: I'd go this way (if you need only one or two instances):
// ADC READ channel + Address selection pins
template <uint8_t ADC_Chan, uint8_t Addr0, uint8_t Addr1, uint8_t Addr2, uint8_t Addr3>
class Mux16b {
public:
void initPins () {
pinMode(Addr0, OUTPUT);
pinMode(Addr1, OUTPUT);
pinMode(Addr2, OUTPUT);
pinMode(Addr3, OUTPUT);
pinMode(ADC_Chan, INPUT);
}
int readMux(uint8_t channel) {
digitalWrite(Addr0, channel&1 != 0);
digitalWrite(Addr1, channel&2 != 0);
digitalWrite(Addr2, channel&4 != 0);
digitalWrite(Addr3, channel&8 != 0);
// maybe some delay to stabilize voltage at the ADC_Chan input ??
return analogRead(ADC_Chan);
}
// not necessary but it's easier to use mux(10) than mux.readMux(10)
int operator()(uint8_t channel) { return readMux(channel); }
};
// analogRead from A0, Address pins: 4 9 5 2
Mux16b<A0,4,9,5,2> mux;
void setup() {
Serial.begin(115200);
mux.initPins();
}
void loop() {
Serial.println(mux.readMux(15));
Serial.println(mux(12)); // using overloaded operator ()
delay(5000);
}