Im making BattleShip on the Arduino:
2 x grid ((10x10 push buttons) + (10x10 led 5mm)) 2 x grid ((10x10 reed switches) + (10x10 led 5mm))
I made a 10x10 grid of push buttons by setting 10 buttons in a row with resistors on each button. By putting it on 5 Volts, each button give an other value of volt to Arduino when pushed.
In this case I got 10 cables from 1 x 10x10 button grid. total 4 grid (40 cables with analog input)
now my question is how to hook up those analog input wires to the Arduino UNO. Can you help me out here? Thanks
/e
im using 1 analog pin to hook up 10 buttons (in code 5 buttons).
Code:
for (int i = 0; i < 10; i++){
if ((voltage[i] >= 0.35) && (voltage[i] <= 0.50) && (gameStatus[i][0] == 0)){ gameStatus[i][0] = 2;}
else if ((voltage[i] >= 0.35) && (voltage[i] <= 0.50) && (gameStatus[i][0] == 1)){ gameStatus[i][0] = 3;}
else if ((voltage[i] >= 1.40) && (voltage[i] <= 1.60) && (gameStatus[i][1] == 0)){ gameStatus[i][1] = 2;}
else if ((voltage[i] >= 1.40) && (voltage[i] <= 1.60) && (gameStatus[i][1] == 1)){ gameStatus[i][1] = 3;}
else if ((voltage[i] >= 2.40) && (voltage[i] <= 2.55) && (gameStatus[i][2] == 0)){ gameStatus[i][2] = 2;}
else if ((voltage[i] >= 2.40) && (voltage[i] <= 2.55) && (gameStatus[i][2] == 1)){ gameStatus[i][2] = 3;}
else if ((voltage[i] >= 3.65) && (voltage[i] <= 3.80) && (gameStatus[i][3] == 0)){ gameStatus[i][3] = 2;}
else if ((voltage[i] >= 3.65) && (voltage[i] <= 3.80) && (gameStatus[i][3] == 1)){ gameStatus[i][3] = 3;}
else if ((voltage[i] >= 4.30) && (voltage[i] <= 4.60) && (gameStatus[i][4] == 0)){ gameStatus[i][4] = 2;}
else if ((voltage[i] >= 4.30) && (voltage[i] <= 4.60) && (gameStatus[i][4] == 1)){ gameStatus[i][4] = 3;}
}