NanoMouse Curriculum

For more information about the NanoMouse, go to

Media source:

Type of learner:
Type of mouse:
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.
  1. Ordering
  3. Khan Academy
  4. Tinkercad
  5. Getting Started
  6. Nano Mouse Nano Mouse Nano Mouse
  7. What is an Arduino? What is an Arduino? What is an Arduino?
  8. Modular Maze Tables Modular Maze Tables (instructions to build a maze table)
  9. 3D Printing the Frame
  10. Tinning Your Soldering Iron Tinning Your Soldering Iron Tinning Your Soldering Iron
      Soldering Safety
    1. Always wear eye protection.
    2. Do not touch the hot end of the soldering iron (you will get an instant 3rd degree burn).
    3. Always put the soldering iron back in its stand. Never put it down on your workbench.
    4. Keep the soldering iron's cable safe (away from hot end).
    5. Never pass a soldering iron to another person.
    6. Turn off (or unplug) the soldering iron when you are done with it.
    7. Wash your hands when you are done soldering.
  11. How to Make a Nano Mouse 3.0 Video
  12. How to Make a Nano Mouse 3.0 Slideshow
  13. 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.
  14. Installing/Using the Arduino IDE
  15. Installing the Arduino core for ESP8266 WiFi chip with Boards Manager
  16. Install CP201x USB to UART Bridge VCP Drivers for Adafruit Feather Huzzah
  17. Example Sketches, Comments, and Reference Example Sketches, Comments, and Reference
  18. How to Upload Your First Program How to Upload Your First Program
  19. Name the program you create in the following video NanoMouse.
    LEDs & Buttons LEDs & Buttons
  20. The Need for Version Control The Need for Version Control
  21. Create a Bitbucket Account
  22. First Commit with Bitbucket First Commit with Bitbucket (25 points)
  23. Name the program you create in the following video CalibrateMotors.
    Test and Calibrate Your Servo Motors Test and Calibrate Your Servo Motors
  24. Before you watch the next video, open your CalibrateMotors program. This is the program you will modify.
    Control the Servo Motors Control the Servo Motors
  25. Movement
  26. Before you watch the next video, open your NanoMouse program. This is the program you will continue to work on for the majority of the course.
    forward() Function forward() Function
  27. Saving Your First Modification Saving Your First Modification  (25 points)
    From now on, you should commit your code every time you finish a lesson.
  28. stop() Function stop() Function
  29. forwardTime() Function forwardTime() Function
  30. turn() Function turn() Function
  31. Improved turn() Function Improved turn() Function
  32. 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:
    Your browser does not support the HTML5 canvas tag.
  33. Improved stop() Function Improved stop() Function
  34. Challenge: Make the turn() Function use Degrees Challenge: Make the turn() Function use Degrees  (25 points)
  35. 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.

    1. Create a square() function that will make your robot trace the path of a square.
    2. 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, you can also refer to the Reference section of the Arduino website).
    3. Modify your function to include an argument to control the size of the square.
    4. Create a similar function to trace the path of an equilateral triangle.
    5. Create a polygon function with arguments to control the size and number of sides.
  36. Robot Art
    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:
    Your browser does not support the HTML5 canvas tag.

    With this function I can easily make all kinds of interesting designs. For example, try putting this at the end of your setup:
    Your browser does not support the HTML5 canvas tag.

    Can you make a spiral? (Hint: you'll need to put your move() function in a loop). What other designs can you make?
  37. Remote Control

    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.

  38. Adding the Bluetooth Module Slide (need offline link)
  39. Create Web App with Cloud9
  40. 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.
  41. Sensors (50 points)
  42. Organizing Your Code Organizing Your Code
    At this point I highly suggest you break down and start learning to use Git. Both codecademy and Udacity offer free courses that explain how to use this tool.
  43. Painting Your Sensors Painting Your Sensors
  44. Adding the Front Sensor
  45. Adding Sensors Slideshow
  46. Adding Sensors Slideshow
  47. Adding a Sensors Class
  48. Adding the Left & Right Detectors
  49. Using Reflected Light
  50. Filtering Out Ambient Light
    This video only covers how to write the code. To understand the theory behind and the benefits of filtering out ambient light, watch the original Nano Mouse version of this lecture (just don't follow along with the coding portion).
  51. Smoothing Smoothing
  52. Obstacle Avoidance (50 points)
  53. Obstacle Detection Obstacle Detection
  54. State Machine State Machine
  55. Improved State Machine Improved State Machine
  56. avoid() Function avoid() Function
  57. Improved avoid() Function Improved avoid() Function
  58. Turn Random Directions Turn Random Directions
  59. Turn Random Durations Turn Random Durations
  60. Navigating a Labyrinth (30 points)
  61. Proportional Control Proportional Control
  62. Amplifying the Error Amplifying the Error
  63. Calibrate targetFront Calibrate targetFront
  64. forwardWhiskers() Function forwardWhiskers() Function
  65. Sensors Threshold Tweak
  66. Navigating a Known Labyrinth Navigating a Known Labyrinth
  67. Navigating an Unknown Labyrinth Navigating an Unknown Labyrinth
  68. Navigating a Known Maze Navigating a Known Maze
  69. Solving a Maze (50 points)
  70. Dynamic Programming / Flood Fill Algorithm Dynamic Programming / Flood Fill Algorithm
  71. Maze Class Maze Class (needs to be updated)
  72. Changing the Mouse's Initial Position and Heading Changing the Mouse's Initial Position and Heading
  73. Initializing the Values Array Initializing the Values Array
  74. Setting the Target Cell Setting the Target Cell
  75. solve() for the North Neighbor solve() for the North Neighbor
  76. Solve() for All Neighboring Cells Solve() for All Neighboring Cells
  77. Adding Virtual Walls Adding Virtual Walls Adding Virtual Walls
  78. solve() Given North Wall solve() Given North Wall
  79. solve() Given Neighboring Walls solve() Given Neighboring Walls
  80. solve() for All Cells solve() for All Cells
  81. Navigating a Maze (50 points)
  82. findBestNeighbor() findBestNeighbor()
  83. findBestNeighbor() Challenge findBestNeighbor() Challenge (15 points)
  84. addWalls() addWalls()
  85. Wirelessly Debugging an espMouse (need offline link)
  86. forwardWhiskers() Modified forwardWhiskers() Modified
  87. scanWalls() scanWalls()
  88. turnTowardBestNeighbor() turnTowardBestNeighbor()
  89. Stepping Through the Maze Stepping Through the Maze
  90. #ifdef DEBUG #ifdef DEBUG
  91. Congratulations Congratulations
  92. Speed Run Tips (need offline link)