// For 2x4 button pad. Prints message and toggles door lock on each press. // Set your serial console to 19200 // Written by Will O'Brien, based on various others works. #define ROWS 2 #define COLS 4 const byte buttonWrite[2] = { 2, 3}; //Pins for the Vin of the buttons const byte buttonRead[4] = { 6, 7, 8, 9}; //Pins for reading the state of the buttons boolean pressed[ROWS][COLS] = { 0}; const byte lock_pin = 4; boolean lockState = 0; void setup(){ Serial.begin(19200); pinMode(lock_pin, OUTPUT); digitalWrite(lock_pin, LOW); //setup the button inputs and outputs for(int i = 0; i < ROWS; ++i){ // ???? Is ROWS the right quanitity here? pinMode(buttonWrite[i], OUTPUT); digitalWrite(buttonWrite[i],LOW); } for(int j = 0; j