Arduino Laser Grid

I have a 16x16 LED Matrix wired into pin 8 of an arduino mega. I also have 5 5mW lasers equally spaced around 2 sides of a square. On the other 2 sides, i have mounted a total of 10 Laser Receiver that output high when laser is detected and low when no laser is detected mounted opposite the lasers.

I want to light up an area of the LED matrix behind where the object landed in the square. I have sampled some code that displays Laser Detected or No laser detected to test the concept. I was thinking of doing these with if statements to check which lasers had been blocked by the object but not sure if there are better ideas. I attached a picture of the concept.

I don’t have a lot of experience with arduino, but have done other programming in VBA and very limited on working with LED Matrix. Any help is greatly appreciated. :slight_smile:

OPs image;

I think you can do it easier if you use 4 beams in each direction, the crossing of each beam being through the middle of the square corresponding to a LED position.

That way you only need to scan your row and column receivers and using the beam in each axis not detected work out the LED to light.

Why you have the beams around the perimeter of each square instead of through the middle of each square?

Tom... :slight_smile:

So your object is bigger than the size of the scanned squares?
You will need to scan your receivers and detect adjacent beams on each axis that are blocked, then workout which square they are the perimeter of.
Will the object always be exactly in the square and blocking 4 beams?

What is the application?

Tom... :slight_smile:

Consider a redesign. Pulse each of the lasers in sequence and also read the sensor in same sequence. This will totally avoid the problem is reflection from whatever object you are placing on the grid. You can do this so fast it will appear that all the lasers are active at once.


Someday when you get tired of working with all that duplicate code, think about putting all the x pin numbers in an x array and the same for the y array. And write the code to use index number to pick up pin number out of the arrays.