I am converting an LCD into a touch screen using ultrasonic sensors. The LCD is connected to my desktop, and I have 7 ultrasonic sensors along the bottom of the LCD, along with 5 on one of the side. The idea is that I would convert the time it takes for the sound waves (from the ultrasonic sensors) to be sent back from a reflecting object into distances. Then convert those distances into mouse movements. I have the Pro Micro and all of the sensors connected to a MEGA2560.
I could use some help figuring out why the code for my mouse movements is not working. It may be because my Pro Micro is not connected to me MEGA2560 properly, however I don’t know how to confirm that (the red LED on the Pro Micro is turned on, but I cant or don’t know how to control it). I am still new to coding, so please explain in detail what I could do to overcome this problem
Note: I only have 10 sensors plugged in, I’m still waiting for two more to arrive before I do the coding for them
That code won't even compile due to an extra/missing braces in setup and loop and the attempt to use 1 as a variable name.
How are the Pro Micro and the MEGA2560 connected together? I see no indication in the code of any mechanism for communication between two boards. The code seems to be written with the intention that the sensor will all be connected directly to the Pro Micro but there aren't even enough pins on the Pro Micro for all those sensors.
I have connected my Mega2560 and Pro Micro to my desktop. However, I need to use both boards for the same project, and they need to work together.
I am converting an LCD into a touch screen using ultrasonic sensors. The LCD is connected to my desktop, and I have 7 ultrasonic sensors along the bottom of the LCD, along with 5 on one of the side. The idea is that I would convert the time it takes for the sound waves (from the ultrasonic sensors) to be sent back from a reflecting object into distances. Then convert those distances into mouse movements. I have the sensors connected to a MEGA2560.
The Pro Micro will convert distances into mouse movements using if statements.
I only know how to control both boards individually, but I dont know how to make them work together.
Heres an updated project description, since a lot has changed.
I am converting an LCD into a touch screen using ultrasonic sensors. The LCD is connected to my desktop, and I have 7 ultrasonic sensors along the bottom of the LCD, along with 5 on one of the side. The idea is that I would convert the time it takes for the sound waves (from the ultrasonic sensors) to be sent back from a reflecting object into distances. Then convert those distances into mouse movements. I have all of the sensors connected to a MEGA2560.
I have since connected my Pro Micro directly to my desktop via a USB to micro USB cable.
I only know how to control the boards individually, but I dont know how to make them work together.
The code I have so far is a combination of code for the senors (Mega2560) and the mouse movements (Pro Micro).
note: I have only been coding for just over a month, so if you could, please explain what I need to do in order to correct any problems.
You're trying to run before you even have learned to crawl. You have a 305 line program and evidently you haven't even bothered testing as you wrote it. This approach will only lead to confusion and wasted time.
The first thing you need to do is to break your project into each of its basic components. Write a simple sketch for each component. Make sure you understand what every single line of each sketch does. If you don't understand then start researching until you do, then move on to the next line. This is what your test sketches should do:
Read distance from the ultrasonic sensor and print it to the Serial Monitor.
Move the mouse.
Send a message from the MEGA2560 to the Pro Micro and make the Pro Micro print that message to the Serial Monitor.
The Arduino IDE and any libraries you're using provide example sketches that may serve for these purposes so you may not even need to write these sketches (but you still need to understand them).
Once you have verified that each of the components work correctly, you can start to combine them. Work incrementally, testing as you go along, rather than just slapping everything together at once and then wondering which of the changes you made broke it.
Save these test sketches to use later for testing if something isn't working correctly.
Note that adding long delays to your sketch is going to make the project less responsive.
Note that you need to make sure to wait long enough between the read on each of the ultrasonic sensors so that echos from the previous sensor's ping will not cause false readings.