Feasibility of thesis prototype

I'm developing a prototype that uses 144 pair of proximity sensors, 2 barcode scanners, and 6 motors (1 stepper and 5 servo). The arduino mega has only 54 i/o pins. Is it possible to use 3 arduino mega using i2c protocol? Or are there any other better ideas to make the project working?

You can get more digital pins with I2C expanders like the MCP23017 (or the SPI version MCP23S17). Each chip adds 16 digital I/O.

How much would one MCP23017 costs?

That, of course, depends on which package (they are available in DIP) and where you buy them. DigiKey has the DIP package for $1.24 US each, on ebay there is an offering of 10 pieces of the DIP package for $8.55 US. You might find a better deal if you look around.

I might need 7 of these to accommodate all the I/O. Do you think it is better to use MCP23017 than using other two arduino mega?

74hc165 is another alternative. Should be very cheap to buy but each chip has only 8 inputs.

Using Megas as simple I/o expanders is wasteful and requires multiple sketches to be written, maintained and uploaded.

What kind of proximity sensors are these? Perhaps a matrix would be possible.

Do you think it is better to use MCP23017 than using other two arduino mega?

I do.

The proximity sensors are pairs of IR LED and photodiode, there is an available proximity sensor module already. Can you tell me a brief concept of the "matrix"?

Additionally, what is the maximum number of MCP23017 that can be connected on an arduino mega or on a single I2C bus?

Please give details of the photodiode module, a link to the product or datasheet. You should post such things without being asked. It should be obvious that we will need to see them. Have you read the forum guidelines in the sticky post yet?

It may be possible to arrange your photodiodes in, for example, a 12x12 matrix. This will require only 24 Arduino pins, 12 digital output pins for the rows and 12 analog input pins for the columns. The Arduino sketch would scan the rows one by one and read the 12 column pins.

However, the circuit on the module may make this idea impossible.

Ok fyi I am building an electronic arbiter for the Game of the Generals ( if you are familiar with the game) and its board is made up of 8 rows and 9 columns, so in total there are 72 rectangles. There will be 144 pair of proximity sensors beneath to determine positions. Why 144 if there are only 72 rectangles? It is because each rectangle is divided into two, each half is exclusively for each player. The electronic arbiter will be a robotic arm ( that's why i mentioned earlier that i will be needing 6 motors). The arm will only activate if both proximity sensors beneath a single rectangle senses an object ( that is called a "challenge" in the game). As a response, the arm will determine the position of the challenging pieces and goes to it to judge them. The ranks will be determined by the barcode scanner, and the losing piece will be picked out of the board automatically, leaving the winning piece in that certain rectangle. The proximity sensor module to be used is just the common IR LED and photodiode, resistors, potentiometer, and the LM358 op-amp (i thought there is no need to tell the details of it because it is common proximity sensor). So, back to what i am asking, how many MCP23017 can be connected to a single arduino mega or to a single I2C bus? Sorry if im too persistent and annoying, im just a beginner on arduino thats why im asking the feasibilty of my project to avoid waste of money and time .

Ok, thanks for the extra info.

To answer your question, the mcp23017 has 3 address pins, which means 8 can be connected to the same i2c bus. That gives you 128 inputs. However, by using additional Arduino pins to connect to the MCP address pins, you can overcome that limit.

If you use 74hc165, you would need 18 chips and 3 Arduino pins. You can buy 10 for US $0.81 on AliExpress.

But if you’re determined to keep the cost down, a matrix would be cheaper and simpler. Just not sure it can be done with those modules. Maybe with the bare photodiodes.

Can the condition i mentioned earlier, ( the robot arm will activate if two sensors on the rectangle detect an object) be met using only bare photodiodes? The sensors are the inputs including the barcode scanner, the motors are the output.

The marix, i think, is an output. What i need is an input from an array of sensors to activate the output (the motors of the arm).

A matrix can be an input or an output. The keyboard on your PC or laptop is a matrix. The keyboard is an input, not an output, yes?

But not all sensors are suitable for making a matrix. It may be possible to make an input matrix with bare photodiodes. But I suspect the module you wish to use will not be suitable for making a matrix.

If bare photodiodes are used in matrix, is there a need for a driver or just directly connect the row and column pins on the arduino I/O pins?

As I understand what you really want to measure is not proximity but whether a spot is occupied or not, right?

Photodiodes are actually analog sensors, but can be read as digital depending on the way you wire them. Same for other light sensors such as LDRs. Alternatives may be magnetic sensors such as hall effect sensors or reed contacts, triggered by a small magnet in the bottom of the game pieces.

Shift registers are probably indeed the cheapest, simplest solution to read such a number of sensors.

As I understand what you really want to measure is not proximity but whether a spot is occupied or not, right?

Yes you are right.

I will try researching about magnetic sensors and how to use them. I will be back soon. Thanks for suggestions.

Hi, You will have to check any sensors range, not just infront of it, but to the sides if they are mounted close to each other.

Tom... :)

Another option is weight - trigger a microswitch as the piece is placed on the board. Easy digital reading, guaranteed no interference with neighbouring parts but more complex to install and it has moving parts. Or even visual - camera mounted above the board.