When COVID-19 first hit, I suddenly found myself with a lot of time on my hands! I was able to work on my projects at home, like my model USS Iowa Battleship and custom Bluetooth controlled Knight Rider KITT car. I frequently updated my programming teacher from school about all my exciting progress, and we shared stories and advice with each other regarding electronics and computer science. Eventually, this led to my school's robotics teacher sending me the mBot and Arduino kits pictured above. I had just one mission: Tinker!
When I first got these two kits, I had already worked quite a bit with Arduinos. I already understood the basics of coding simple LED or motor circuits, and I had already combined them to create projects like my Bluetooth KITT car. As such, I decided to challenge myself! New components, such as the ultrasonic sensor and photoresistor caught my eye, and project ideas began forming in my head.Â
Since I had never used a photoresistor before, I started off with making a project based on that. After some quick research, I realized that a photoresistor works by changing it's resistance based on the amount of light that hit's its surface. This is useful in a circuit because the arduino can then sense the variable resistance and thus sense the change in light. By using an LED to simulate changes in daylight and programming the Arduino to control a motor based on the photoresistor, I had myself a solar operated motor!
For my next experiment, I decided to mess around with the LCD. After following some circuit diagrams that I found online and testing out the pre-written code for the LCD game that I found online, I decided to try creating my own timer and scrolling text. This was a bit more fun since it was my own programming. I also noticed how similar this screen looks to the ones used on water bottle refilling stations, and I think there could be a lot of interesting applications of this little screen in future projects.
Moving on to the mBot kit, I soon discovered that the included firmware and programming software was horrendous. Their recommended app did not work with the robot, and the programming software was based on scratch. To get around all of this, I decided to download an Arduino library for the mBot so that I could create my own mBot programs in the Arduino IDE. So much more freedom! Let's begin.
First, I created a program to utilize the ultrasonic sensor that came with the mBot. This allowed me to track the distance of objects in front of the mBot, and when the distance became too small, the mBot can back up and turn in a random direction to find a bettter path with less obstacles. This worked well, but it would be improved with better visibility from the sides. This will be covered shortly.
Next, I programmed the mBot to use the IR sensor on the bottom of the robot to track different surfaces. This allowed me to make the mBot follow a black line. When both IR sensors are inside the line, the mBot moves forward. When one side strays too far, the mBot turns to correct itself. When both IR sensors are out, then the mBot backs up to find the line.
It was at this point that I decided I want to start making my own modifications to the mBot. Remember how I said that the ultrasonic sensor can only look forward and limits the robot's field of view? Well, let's fix that with some IR sensors. However, IR sensors only work within a certain range, so I decided to design and print a bumper that keeps the sensors at least 5cm away from any objects in its front or on its sides.
Because of the proprietary nature of the mBot, the additional IR distance sensors cannot be simply connected to the circuit board. Instead, it must first go through the RJ25 module shown that then connects to on of the ports on the mBot. This also requires some adjustment to the programming method, as we shall discuss below.
With the IR sensors added and bumper attached, I decided to create an advanced version of my obstacle avoidance code. First, I added logic to my program that takes in data from the side sensors to make guided decisions on the best direction to turn. Next, I decided to combine the program with my black line follower code because the black line sensor will detect black if the floor is too far away. Thus, I had created myself a robot that both prevents itself from hitting a wall and prevents itself from going over an edge.
Next, I decided to modify my advanced obstacle avoidance program so that it only uses the right IR sensor. This allowed me to create a program that keeps the mBot moving forward while staying within a certain distance of the wall on its right side. It can handle corners really well once the timing is calibrated correctly. As shown, it can also go around a corner to find the next wall when the original wall ends! This could be pretty convenient for the purpose of mapping a room, and I think I'll try to do that in a future project.
These were some pretty fun kits to mess around with, and I got the chance to learn some new things about certain electronics and programming methods. I look forward to using what I learned to make my next DIY programming project. In the meantime, the full code I made and used for these projects can be found on my Github.