我也发布了这个问题here .

我正在连接MUX74HC4067并读取每个引脚的值 . 所有的值保持一致,直到达到227然后重新开始 . 我不确定有什么问题我稍后会设置引脚,因为我最终会从ini文件中检索这些引脚,以便在它完全正常工作时配置它 .

串行监视器输出以下内容作为简短示例:

Push button at channel 0 is 197
Push button at channel 1 is 197
Push button at channel 2 is 197
Push button at channel 3 is 197
Push button at channel 4 is 197
Push button at channel 5 is 197
Push button at channel 6 is 197
Push button at channel 7 is 197
Push button at channel 8 is 197
Push button at channel 9 is 197
Push button at channel 10 is 197
Push button at channel 11 is 197
Push button at channel 12 is 197
Push button at channel 13 is 197
Push button at channel 14 is 197
Push button at channel 15 is 197

Push button at channel 0 is 227
Push button at channel 1 is 227
Push button at channel 2 is 227
Push button at channel 3 is 227
Push button at channel 4 is 227
Push button at channel 5 is 227
Push button at channel 6 is 227
Push button at channel 7 is 227
Push button at channel 8 is 227
Push button at channel 9 is 227
Push button at channel 10 is 227
Push button at channel 11 is 227
Push button at channel 12 is 227
Push button at channel 13 is 227
Push button at channel 14 is 227
Push button at channel 15 is 227
#include "MUX74HC4067.h"

// Creates a MUX74HC4067 instance
// 1st argument is the Arduino PIN to which the EN pin connects
// 2nd-5th arguments are the Arduino PINs to which the S0-S3 pins connect

MUX74HC4067 *pmux1 = NULL;

void setup()
{
MUX74HC4067 pmux1(22,23,24,25,26);

Serial.begin(9600);  // Initializes serial port
 // Waits for serial port to connect. Needed for Leonardo only
while ( !Serial ) ;

// Configures how the SIG pin will be interfaced
// e.g. The SIG pin connects to PIN 3 on the Arduino,
//      and PIN 3 is a digital input
//  mux1.signalPin(27, INPUT, DIGITAL);
 pmux1.signalPin(27, INPUT, DIGITAL);
}

// Reads the 16 channels and reports on the serial monitor
// if the corresponding push button is pressed
void loop()
{
 byte data;

for (byte i = 0; i < 16; ++i)
{
    // Reads from channel i and returns HIGH or LOW
data = pmux1->read(i);


    Serial.print("Push button at channel ");
    Serial.print(i);
    Serial.print(" is ");
   Serial.println(data);
    if ( data == HIGH ) Serial.println("not pressed");
    else if ( data == LOW ) Serial.println("pressed");
}
Serial.println();

delay(1500);
}

这是library mux的链接 .

这行代码检索值并在教程中:

data = mux1.read(i);

并且工作正常 .

我改为以下,因为当所有工作时,将从INI文件设置引脚 .

data = pmux1->read(i);

我很遗憾,因为它们也是高或低的 .