No. I think it may work with OP's board.
Yes, that's all that was supposed to happen. If you can detect each key then it's possible to generate some code for debouncing, etc.
The intent was to replicate the original lamp controller function in a new MCU. Been on back burner for awhile now.
The buttons on the OP's board aren't wired in a standard 2x2 matrix layout. However, the approach of temporarily setting a line to output LOW can effectively be used to read B4 (as long as only one button is pressed at a time). For example in this code, B1_state .. B4_state take the value 1 (HIGH) when the corresponding button is pressed.
bool B1_state, B2_state, B3_state, B4_state;
#define CLK_pin ...
#define STB_pin ...
#define DAT_pin ...
//----------------------------------------
void setup() {
setAllPullup();
}
//----------------------------------------
void loop() {
setToRead_B4();
B4_state = !digitalRead(STB_pin)
setAllPullup();
B1_state = !digitalRead(CLK_pin)
B2_state = !digitalRead(STB_pin)
B3_state = !digitalRead(DAT_pin)
...
}
//----------------------------------------
void setToRead_B4() {
pinMode(CLK_pin, OUTPUT);
digitalWrite(CLK_pin, LOW);
}
//----------------------------------------
void setAllPullup() {
pinMode(CLK_pin, INPUT_PULLUP);
pinMode(STB_pin, INPUT_PULLUP);
pinMode(DAT_pin, INPUT_PULLUP);
}
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.