Prerequisites
- Ordering
-
Code.org
- Khan Academy
- Tinkercad
Getting Started
-
Nano Mouse
Nano Mouse
Nano Mouse
-
What is an Arduino?
What is an Arduino?
What is an Arduino?
-
Modular Maze Tables
Modular Maze Tables
(instructions to build a maze table)
-
3D Printing the Frame
-
Tinning Your Soldering Iron
Tinning Your Soldering Iron
Tinning Your Soldering Iron
Soldering Safety
- Always wear eye protection.
- Do not touch the hot end of the soldering iron (you will get an instant 3rd degree burn).
- Always put the soldering iron back in its stand. Never put it down on your workbench.
- Keep the soldering iron's cable safe (away from hot end).
- Never pass a soldering iron to another person.
- Turn off (or unplug) the soldering iron when you are done with it.
- Wash your hands when you are done soldering.
-
How to Make a Nano Mouse 3.0 Video
-
How to Make a Nano Mouse 3.0 Slideshow
-
Populate Your LogoMouse Circuit Board
Populate Your LogoMouse Circuit Board
Populate Your LogoMouse Circuit Board
-
Assemble Your LogoMouse Power Cable
Assemble Your LogoMouse Power Cable
Assemble Your LogoMouse Power Cable
-
Assemble Your LogoMouse Robot
Assemble Your LogoMouse Robot
Assemble Your LogoMouse Robot
-
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.
-
Installing/Using the Arduino IDE
-
Installing the Arduino core for ESP8266 WiFi chip with Boards Manager
-
Install CP201x USB to UART Bridge VCP Drivers for Adafruit Feather Huzzah
-
Example Sketches, Comments, and Reference
Example Sketches, Comments, and Reference
-
How to Upload Your First Program
How to Upload Your First Program
- Name the program you create in the following video NanoMouse.
LEDs & Buttons
LEDs & Buttons
-
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.
-
espMouse Note #3: You will need to add
yield();
inside the while loop that is used to listen for the button press. For information on why, refer to https://github.com/esp8266/Arduino/blob/master/doc/reference.md#timing-and-delays
-
The Need for Version Control
The Need for Version Control
- Create a Bitbucket Account
-
First Commit with Bitbucket
First Commit with Bitbucket
(25 points)
- Name the program you create in the following video CalibrateMotors.
Test and Calibrate Your Servo Motors
Test and Calibrate Your Servo Motors
- espMouse Note: The How to Make an espMouse slideshow directs you to connect your Servos to pins 14 & 12, so change your code accordingly.
-
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
Movement
-
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
-
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:
-
Saving Your First Modification
Saving Your First Modification
(25 points)
From now on, you should commit your code every time you finish a lesson.
-
stop() Function
stop() Function
-
forwardTime() Function
forwardTime() Function
-
turn() Function
turn() Function
- 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).
-
Improved turn() Function
Improved turn() Function
- 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:
-
Improved stop() Function
Improved stop() Function
-
Challenge: Make the turn() Function use Degrees
Challenge: Make the turn() Function use Degrees
(25 points)
-
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.
-
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:
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?
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.
-
Renaming the Bluetooth Module
Renaming the Bluetooth Module
-
Adding the Bluetooth Module Slide (need offline link)
-
Adding the Bluetooth Module
Adding the Bluetooth Module
-
-
Android
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.
Tutorials
- Beginner Video Tutorials
- Magic 8-Ball
- MoleMash
- Controller Android App
- Pairing with an Android Device and Running Your App
-
Name the program you create in the following video Bluetooth Remote.
Programming the Arduino as a Receiver
Programming the Arduino as a Receiver
-
Android Remote Control Challenge
- You may have noticed that when you disconnect from your robot while it's moving, it continues to move. Fix this bug so that your robot stops when you disconnect from it.
- Send and receive a 3rd message from your Android device to your Arduino to control the onboard LED.
- Send and receive a 4th message from your Android device to your Arduino to "honk a horn" (make noise with the buzzer).
-
Create Web App with Cloud9
-
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.
Sensors (50 points)
-
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.
-
Painting Your Sensors
Painting Your Sensors
-
Adding the Front Sensor
-
Adding Sensors Slideshow
-
Adding Sensors to Your LogoMouse
Adding Sensors to Your LogoMouse
-
Adding a Sensors Class
Adding a Sensors Class
-
Adding the Left & Right Detectors
Adding the Left & Right Detectors
-
Logo Mouse Note: The left detector is connected to pin A7. See the Logo Mouse page for more info.
-
Using Reflected Light
Using Reflected Light
-
Filtering Out Ambient Light
Filtering Out Ambient Light
-
Adding Sensors Slideshow
-
Adding a Sensors Class
-
Adding the Left & Right Detectors
-
Using Reflected Light
-
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).
-
Smoothing
Smoothing
-
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.
Obstacle Avoidance (50 points)
-
Obstacle Detection
Obstacle Detection
-
State Machine
State Machine
-
Improved State Machine
Improved State Machine
-
avoid() Function
avoid() Function
-
Improved avoid() Function
Improved avoid() Function
-
Turn Random Directions
Turn Random Directions
-
Turn Random Durations
Turn Random Durations
Navigating a Labyrinth (30 points)
-
Proportional Control
Proportional Control
- 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).
-
Amplifying the Error
Amplifying the Error
-
Calibrate targetFront
Calibrate targetFront
-
forwardWhiskers() Function
forwardWhiskers() Function
- Sensors Threshold Tweak
-
Navigating a Known Labyrinth
Navigating a Known Labyrinth
-
Navigating an Unknown Labyrinth
Navigating an Unknown Labyrinth
-
Navigating a Known Maze
Navigating a Known Maze
Solving a Maze (50 points)
-
Dynamic Programming / Flood Fill Algorithm
Dynamic Programming / Flood Fill Algorithm
-
Maze Class
Maze Class
(needs to be updated)
-
Changing the Mouse's Initial Position and Heading
Changing the Mouse's Initial Position and Heading
-
Initializing the Values Array
Initializing the Values Array
-
Setting the Target Cell
Setting the Target Cell
-
solve() for the North Neighbor
solve() for the North Neighbor
-
Solve() for All Neighboring Cells
Solve() for All Neighboring Cells
-
Adding Virtual Walls
Adding Virtual Walls
Adding Virtual Walls
-
solve() Given North Wall
solve() Given North Wall
-
solve() Given Neighboring Walls
solve() Given Neighboring Walls
-
solve() for All Cells
solve() for All Cells
Navigating a Maze (50 points)
-
findBestNeighbor()
findBestNeighbor()
-
findBestNeighbor() Challenge
findBestNeighbor() Challenge (15 points)
-
addWalls()
addWalls()
- Wirelessly Debugging
-
Wirelessly Debugging an espMouse (need offline link)
-
forwardWhiskers() Modified
forwardWhiskers() Modified
-
scanWalls()
scanWalls()
-
turnTowardBestNeighbor()
turnTowardBestNeighbor()
-
Stepping Through the Maze
Stepping Through the Maze
-
#ifdef DEBUG
#ifdef DEBUG
-
Congratulations
Congratulations
-
Speed Run Tips (need offline link)