Week 12: Range Finder and Display
This week, we brought together a lot of what we learned through the entire module, combining electronics and the Arduino even more than we did the week before. We already know how to give the LCD display a specific text or outcome that is predetermined. This week, we will be making the display more dynamic, by having it display readings that are being recorded by an ultrasonic range finder.
We are starting off by seeing if the range finder works and we are able to collect data and have that data be displayed in real-time in the software serial monitor. The first step was hooking the range finder itself to the Arduino. Following the instructions in the document below which was given to us by our lecturer, I was able to quickly get on with working with the software to actually start finding ranges.
XE 404 Arduino Ultrasonic and Display
Once the range finder was connected to the Arduino, there was a custom .ino code file that was given to us, which would allow the Arduino to be compatible with the range finder, which I needed to put in a folder in the Arduino folder on my laptop. How to find the Arduino folder can be found in my week 11 post, but below is an image of how the Arduino folder looks on my laptop.I then opened the .ino file on the Arduino software, and ran the code, making sure that the Arduino was connected via USB and that once again that the range finder was hooked up properly, and the results can be seen below. Further below that, is a snapshot of the code.
ULTRASONIC RANGE FINDER FIRST TEST VIDEO
Finding that my test of the range finder worked very well, I then moved on to try and combine the skills I’ve learned from week 11 and combine it with this week’s assignment to try and make the LCD display dynamically show the readings from the range finder. To do this, I needed the library I had installed the previous week to ake the LCD display work properly, so if you haven’t already checked out week 11s content, make sure to.
I took the code from week 11 and merged it with the code received this week, taking both of the “void setup”‘s and “void loop”‘s and making sure both were together in the same piece of code. It looks like a large jumbled mess, but this is where I learned that you can only have one “void setup” and “void loop” which is why I needed to merge the two. Below is a snapshot of the part of the merged code.
sss An issue I ran into was with the amount of wiring I had to do to complete this. I only had 3 one set of compensators to connect both the range finder and the LCD display to the Arduino. So the fix I came up with was to simply directly insert the range finder into the Arduino as instructed by my lecturer. It looks a bit messy and may have some side effects, but the outcome worked, below is an image of how the setup looked like.
ss Once both things were connected to the Arduino, I tried to run the code, and found failure. I had apparently messed up slightly when coding the Arduino to be able to have the range finder plugged in directly, forgetting to turn the correct pin into a power outlet, but it was a quick fix that led to the whole ordeal working out. Although it was slow, and sometimes inaccurate, below is a video of the range finders results being shown in the LCD display, with the .ino file of the final code which I used to make it work.