Student: Reveals only the lessons needed to build and program a mouse.
Teacher/Hobbyist: Reveals additional lessons on ordering parts, building a maze table, and programming the Bluetooth module.
Type of mouse:
NanoMouse: Best choice for students who are building a robot that they will take home, and who have an Android device.
espMouse: Best choice for students who are building a robot that they will take home, and who have an iPhone.
LogoMouse: Best choice for younger students who are building their own robot, and for teachers who want a classroom set.
The first type of robotic mouse I developed was the NanoMouse. It uses an Arduino Nano as the brain. In response to demand for a mouse that could connect to an iPhone, I developed the espMouse which uses an esp8266 as the brain. When I became a middle school teacher, I needed something that could withstand a little abuse, so I developed the LogoMouse which uses a printed circuit board instead of a breadboard.
All official Arduino Nanos, and many Arduino Nano clones use the standard FTDI Chip drivers which you can download from http://www.ftdichip.com/Drivers/VCP.htm (not necessary for Windows 10 users).
Some Arduino clones use a CH340/CH341 USB to serial communication chip and the standard drivers won't work. To program it, you must download and install the CH341 drivers from http://www.wch.cn/downloads.php?name=pro&proid=65. Warning!!! The CH340/CH341 chips do not work well. I highly recommend you buy Arduinos or Arduino clones that use FTDI chips.
To tell which type of driver your Arduino uses, flip it over and look at the chip on the back. It will either say FTDI or CH340 (along with some other letters and numbers).
How to Make an espMouse 2.0 Slideshow (uses Adafruit's Feather HUZZAH)
Although the How to Make a Nano Mouse video is specific to the Nano Mouse, I suggest you watch it (but don't start building) just to get a general idea of what you're about to do. Then, follow the instructions in the slideshow.
espMouse Note #1: The onboard LED for the Adafruit Feather Huzzah ESP8266 is attached to pin 2 and is turned on when the pin is set LOW (counterintuitive and annoying). For this reason, you will need to add a line of code prior to the while loop that sets the led HIGH to turn it off and change the line of code that comes after the while loop so that it sets the led LOW (to turn it on after the button is pressed).
espMouse Note #2: The How to Make an espMouse slideshow directs you to connect the button to pin 0, so change your code accordingly.
SM-S4303R Servo Note: Originally I made these videos with Parallax motors which have a range of 1500±200, and for reasons that will become clear later in the course I instruct you to power your mouse at half speed (100). I have since switched to using the SM-S4303R servos which have a range of 1500±500. If you are using these motors, you should set the power level for your mouse at 250 (half power).
SM-S4303R Servo Note: These servos turn in the opposite direction compared to the Parallax motors used in this video. As a consequence, you will need to reverse the maner in which power is added to and subtracted from the stop signal as follows:
SM-S4303R Servo Note: Remember, these servos turn in the opposite direction compared to the Parallax servos. As a consequence, you must reverse the manner in which power is added to and subtracted from the stop signal (see the note from the forward() Function lecture).
The amount of time it take your robot to turn left 90 degrees will probably be different from the amount of time it takes it to turn right 90 degrees. To fix this, you can use an if statement to set different times based on whether you're robot is turning left or right. Assuming 4.9 is the correct multiplier for right turns, and 5.1 is the correct multiplier for left turns, your turn function would look something like:
Movement Challenge (25 points)
Once you are able to make your robot move forward and turn as desired, challenge yourself by programming your robot to do the following. Work through Khan Academy's Intro to JS course to get a better handle on programming prior to attempting this challenge. If you don't want to work through the entire course, then just work through the following sections:
Feel free to ask questions. This is a difficult challenge. You are not expected to complete it independently.
Create a square() function that will make your robot trace the path of a square.
If you haven't already, use a for loop to eliminate any repetitive code. (In addition to learning about for loops via Khan Academy or Code.org, you can also refer to the Reference section of the Arduino website).
Modify your function to include an argument to control the size of the square.
Create a similar function to trace the path of an equilateral triangle.
Create a polygon function with arguments to control the size and number of sides.
The functions you have created so far will allow you to draw polygons and navigate a maze, but they do not give you full access to your robot's artistic abilities. Whenever I want to make a robot draw something cool, I add a move() function that allows me to easily control both motors with a single command:
With this function I can easily make all kinds of interesting designs. For example, try putting this at the end of your setup:
Can you make a spiral? (Hint: you'll need to put your move() function in a loop). What other designs can you make?
This section of the course covers how to remotely control your Nano/Logo/esp Mouse. If you do not have the hardware or the desire to complete this section, you can safely skip it and still learn everything you need to make your Nano Mouse solve a maze.
That said, learning to remote control your robot is a lot of fun. You can control a Nano/Logo mouse using the track pad of a Macintosh computer, or the accelerometer of an Android phone/tablet. You can control an espMouse using any WiFi enabled device (including iPhones and Blackberries).
Personally, I prefer writing an Android specific app that uses Bluetooth. The Nano/Logo mice work better, and the communication between the remote and the receiver is more robust. If you do not have an Android tablet or cell phone, I highly recommend purchasing one because writing your own Android apps is easy, free, and fun with App Inventor 2 (this is not the case with Apple products). Also, Android phones/tablets are equipped with various sensors that you can use to augment what you do with your Arduino (or any other microcontroller for that matter). Amazon's Kindle Fire is almost certainly the least expensive tablet you can purchase for this purpose and is what I use with my students. If you are an educator working with a classroom full of students, you can get away with just a few tablets as your students will likely reach this section at different times.
In order to build your own app to remote control your Nano/Logo Mouse, you need access to App Inventor, which is a web based program that requires users to login with a Google account. I highly encourage you to make an extra effort to access App Inventor as it is a fantastic tool to create real apps quickly and easily. However, if that simply is not possible, use my NanoMouseRemote app.
Prior to coding an Android app to remote control your robot, I recommend working through some beginner tutorials so that you understand what you're doing before you work through my video tutorials.
Host from an esp8266
After making this video, I discovered I got better results if I put the line that creates the access point towards the top of the setup (directly below the 1000 millisecond delay), and the code that creates the servo objects and sets them to stop towards the bottom of the setup.
espMouse Note: This lesson was originally created for the Nano Mouse, but you should be able to follow along and use it to add smoothing to your espMouse's sensors. Just don't change code you wrote in previous sensor lessons to match what was developed prior to this video.
SM-S4303R Servo Note: Remember, these servos turn in the opposite direction compared to the Parallax servos. As a consequence, you must reverse the manner in which power and the error term is added to and subtracted from the stop signal (see the note from the forward() Function lecture).