Wonder if anybody here could help me figure out how the wiring of this project has been done. I guess if I got atleast a schematic diagram for this project, I can be able to make this project work (I wish :.) . I got a resource from the internet but I'm a newbie and I still got to learn more. It would be a good start if you could help me out. I'm trying to make a chess playing robot. For the chess sensory board, I need 64 reed switches for each squares of the board. The opponent will be the robot itself and it will move the pieces using motors. I'm having a hard time in how can I be able to connect everything. I guess it would be better posting the link for further understanding. http://www.instructables.com/id/How-to-Build-an-Arduino-Powered-Chess-Playing-Robo/?ALLSTEPS
this is the program for the chess sensory board
#include <SoftwareSerial.h>
//Give convenient names to the control pins
#define CONTROL0 5
#define CONTROL1 4
#define CONTROL2 3
#define CONTROL3 2
#define rxPin 10
#define txPin 11
//Create arrays for data from the the MUXs
//See the Arduino Array Reference: http://www.arduino.cc/en/Reference/Array
int mux0array[16];
int mux1array[16];
int mux2array[16];
int digitalpins[16];
int mux0arraycheck[16];
int mux1arraycheck[16];
int mux2arraycheck[16];
int digitalpinscheck[16];
int descrepicount = 0;
char * squares[] = {"A1","A2","A3","A4","A5","A6","A7","A8","B1","B2","B3","B4","B5","B6","B7","B8","C1","C2","C3","C4","C5","C6","C7","C8","D1","D2","D3","D4","D5","D6","D7","D8","E1","E2","E3","E4","E5","E6","E7","E8","F1","F2","F3","F4","F5","F6","F7","F8","G1","G2","G3","G4","G5","G6","G7","G8","H1","H2","H3","H4","H5","H6","H7","H8"};
int lastprinted;
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
void setup()
{
//Set MUX control pins to output
pinMode(CONTROL0, OUTPUT);
pinMode(CONTROL1, OUTPUT);
pinMode(CONTROL2, OUTPUT);
pinMode(CONTROL3, OUTPUT);
for(int i=23; i < 39; i++){
pinMode(i, INPUT);
}
//Open the serial port at 9600 bps
Serial.begin(9600);
Serial.println("Startup");
//Set analog pins to digital input
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
//Turn on pullup resistors
digitalWrite(A0, HIGH);
digitalWrite(A1, HIGH);
digitalWrite(A2, HIGH);
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
/*for(int i = 0; i < 16; i++){
digitalpins[i] = 1;
digitalpinscheck[i] = 1;
}*/
}
void loop()
{
for (int i=0; i<16; i++)
{
//The following 4 commands set the correct logic for the control pins to select the desired input
//See the Arduino Bitwise AND Reference: http://www.arduino.cc/en/Reference/BitwiseAnd
//See the Aruino Bitshift Reference: http://www.arduino.cc/en/Reference/Bitshift
digitalWrite(CONTROL0, (i&15)>>3);
digitalWrite(CONTROL1, (i&7)>>2);
digitalWrite(CONTROL2, (i&3)>>1);
digitalWrite(CONTROL3, (i&1));
//Read and store the input
//Since internal pullup is on, the pin goes low on changing, so the value needs to be flipped from 0 to 1 (!)
mux0array[i] = !digitalRead(A0);
}
//This for loop is used to scroll through the SECOND multiplexer
for (int i=0; i<16; i++)
{
digitalWrite(CONTROL0, (i&15)>>3);
digitalWrite(CONTROL1, (i&7)>>2);
digitalWrite(CONTROL2, (i&3)>>1);
digitalWrite(CONTROL3, (i&1));
mux1array[i] = !digitalRead(A1);
}
//This for loop is used to scroll through the THIRD multiplexer
for (int i=0; i<16; i++)
{
digitalWrite(CONTROL0, (i&15)>>3);
digitalWrite(CONTROL1, (i&7)>>2);
digitalWrite(CONTROL2, (i&3)>>1);
digitalWrite(CONTROL3, (i&1));
mux2array[i] = !digitalRead(A2);
}
for (int b = 0; b < 16; b++){
digitalpins[b] = digitalRead(b + 23);
}
//delay(1000); //Wait for the computer to move so we don't detect any false input from the other magnets
//it adds 12 seconds to startup time but that doesn't really matter... we're setting the board up anyway :)
//sets the array to digitalreads of built in mega pins 23 - 39
//This for loop is used to scroll through and store the 16 inputs on the FIRST multiplexer
for (int i=0; i<16; i++)
{
//The following 4 commands set the correct logic for the control pins to select the desired input
//See the Arduino Bitwise AND Reference: http://www.arduino.cc/en/Reference/BitwiseAnd
//See the Aruino Bitshift Reference: http://www.arduino.cc/en/Reference/Bitshift
digitalWrite(CONTROL0, (i&15)>>3);
digitalWrite(CONTROL1, (i&7)>>2);
digitalWrite(CONTROL2, (i&3)>>1);
digitalWrite(CONTROL3, (i&1));
//Read and store the input
//Since internal pullup is on, the pin goes low on changing, so the value needs to be flipped from 0 to 1 (!)
mux0array[i] = !digitalRead(A0);
}
//This for loop is used to scroll through the SECOND multiplexer
for (int i=0; i<16; i++)
{
digitalWrite(CONTROL0, (i&15)>>3);
digitalWrite(CONTROL1, (i&7)>>2);
digitalWrite(CONTROL2, (i&3)>>1);
digitalWrite(CONTROL3, (i&1));
mux1array[i] = !digitalRead(A1);
}
//This for loop is used to scroll through the THIRD multiplexer
for (int i=0; i<16; i++)
{
digitalWrite(CONTROL0, (i&15)>>3);
digitalWrite(CONTROL1, (i&7)>>2);
digitalWrite(CONTROL2, (i&3)>>1);
digitalWrite(CONTROL3, (i&1));
mux2array[i] = !digitalRead(A2);
}
////////////Check if anything has changed...
for (int b = 0; b < 16; b++){
if(digitalpinscheck[b] != digitalpins[b]){
if(lastprinted != b || descrepicount == 0){
Serial.print((squares[b]));
lastprinted = b;
descrepicount = descrepicount + 1;
}
if(descrepicount >= 2){
Serial.println();
descrepicount = 0;
}
}
}
for (int b = 0; b < 16; b++){
if(mux0arraycheck[b] != mux0array[b]){
if(lastprinted != b || descrepicount == 0){
Serial.print((squares[b + 16]));
lastprinted = b;
descrepicount = descrepicount + 1;
}
if(descrepicount >= 2){
Serial.println();
descrepicount = 0;
}
}
}
for (int b = 0; b < 16; b++){
if(mux1arraycheck[b] != mux1array[b]){
if(lastprinted != b || descrepicount == 0){
Serial.print((squares[b + 32]));
lastprinted = b;
descrepicount = descrepicount + 1;
}
if(descrepicount >= 2){
Serial.println();
descrepicount = 0;
}
}
}
for (int b = 0; b < 16; b++){
if(mux2arraycheck[b] != mux2array[b]){
if(lastprinted != b || descrepicount == 0){
Serial.print((squares[b + 48]));
lastprinted = b;
descrepicount = descrepicount + 1;
}
if(descrepicount >= 2){
Serial.println();
descrepicount = 0;
}
}
}
////////////////////////////////////////////////
for (int b = 0; b < 16; b++){
digitalpinscheck[b] = digitalpins[b];
}
for (int b = 0; b < 16; b++){
mux2arraycheck[b] = mux2array[b];
}
for (int b = 0; b < 16; b++){
mux1arraycheck[b] = mux1array[b];
}
for (int b = 0; b < 16; b++){
mux0arraycheck[b] = mux0array[b];
}
//////////////////////////////////////////////
}
/*
//DEBUG
//The following lines are for printing out results of the internal pins
Serial.print("internal pins: ");
for (int i=0; i<16; i++)
{
Serial.print(digitalpins[i]);
Serial.print(",");
}
Serial.println(); //line feed
//The following lines are for printing out results of array0
Serial.print("mux0array: ");
for (int i=0; i<16; i++)
{
Serial.print(mux0array[i]);
Serial.print(",");
Serial.print(mux0array[i]);
Serial.print(",");
}
Serial.println(); //line feed
//The following lines are for printing out results of array1
Serial.print("mux1array: ");
for (int i=0; i<16; i++)
{
Serial.print(mux1array[i]);
Serial.print(",");
Serial.print(mux1array[i]);
Serial.print(",");
}
Serial.println();
//The following lines are for printing out results of array2
Serial.print("mux2array: ");
for (int i=0; i<16; i++)
{
Serial.print(mux2array[i]);
Serial.print(",");
Serial.print(mux2array[i]);
Serial.print(",");
}
Serial.println();
delay(1000);
}
*/
Please chip in. Any help would be highly appreciated. Thank you. God Speed.