Thank you a lot, now i understand more less how it work, appriciate your help!
CrossRoads:
Have 18 digital I/O available outside of Rx/Tx that are commited to serial port in this case. Use 15 of them:
D2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
(A0-A5 are also D14-D19)Why resistors at all? Use internal pullups on input pins, buttons close to ground.
// I'm totally winging it here, may need to check the Reference page for syntax on a couple of things...
byte D[15]; // declare 15 element array
D[ ] = {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; // map the Dx pins into the array, D[0] represents D2 ... D[14] represents D16
int x; // variable we'll use a bunch
void setup(){
for (x = 0; x<15; x=x+1){ // setup a loop to go from 0 to 14 to access the array elements
pinMode (D[x], INPUT); // set the pins as inputs, recall: D[0] = D2
digitalWrite (D[x], HIGH); // enables internal pullup
Serial.begin(9600); // library takes care of setting D0, D1 as needed
} // end setup
void loop(){
for (int x =0; x<15; x=x+1){ // set to read D[0] to D[14],
if (digitalRead (D[x]) == 0){ // is a button pushed?
value = x; // store the array index (?) that was found low, i.e. button was pushed
// now act on the button that was pushed
switch (value){ // use this to jump to the code for the button that was pushed
case 0:
// code for D2
Serial.println(" button on D2 was pressed");
break;
case 1:
// code for D3
Serial.println(" button on D3 was pressed");
break;
//etc
case 14:
//code for D16
Serial.println(" button on D16 was pressed");
break;
} // end switch
} // end if button pushed, go read the next one
} // end void loop
Give it a shot, see how it goes