Using the Midnight Make Programmer
Overview
The Midnight Make Programmer is a LUFA-based programmer that can be used to upload custom code to any Midnight Make kit.
Be sure you've completed the steps in the programmer setup guide first, otherwise the instructions in this guide will not work.
1. Compile Your Code
How you compile code will depend on your preferred workflow and operating system. To accomplish this see the guide on working with source code.
Once you've compiled your code, or if you're working with the pre-compiled example code, you can proceed to the next step.
2. Connect the Programmer
Using the provided 6-pin cable, connect the programmer to your Midnight Make kit (such as the µBee or the Pocket Bot). Connect your computer to the programmer using the provided USB-C to USB-A cable. See the image below for reference.

You can also use your own cable (including USB-C to USB-C, if that is preferred), as long as it is a data cable and not just a charging cable.
3. Power Your Kit
Midnight Make Kits must be turned on to be programmed. Attempting to program them while unpowered can permanently damage them.
If you're programming the µBee drone, plug its battery in. If you're programming the Pocket Bot, plug its battery in and turn it on.
CAUTION. Uploading code to robots or drones can be hazardous if you are careless. Incorrect code can cause drones to suddenly take off, or robots to run off the table (also taking cables with them), and this happens even to experienced engineers. Be mindful of your workspace and surroundings, be cautious, and use protective equipment.
4. Invoke AVRDUDE
All of our example code comes with easy-to-use scripts for uploading your compiled code to your Midnight Make kit, via avrdude. Be sure you've completed the avrdude setup (available here) and configured your PATH environment variable accordingly so that avrdude can be found.
For Windows, run the provided program-win.sh script from the command line.
For Linux, run the provided program-linux.bash script from the terminal.
After running, you should see successful output like this:

The line:
avrdude: 11230 bytes of flash verified
indicates your kit was successfully programmed. (The actual number of bytes will vary, so it's okay if that number differs from 11230.)
If you see messages like this, congratulations! This indicates that programming was successful. Your connected Midnight Make kit will reboot automatically and run your uploaded code.
Troubleshooting
Hardware devices are complex and communication can sometimes fail, preventing programming. Fortunately, the causes are usually easy to find and fix within a few minutes. Even experienced engineers struggle with failed cables, forgetting to turn on devices, or other simple sources of error that are almost always user-induced.
Here are some common causes of programming failure.
-
avrdudeis not found, usually indicated by a message such asavrdude: command not found. This occurs because yourPATHenvironment variable does not contain a path to theavrdudeexecutable. Be sure to configure this correctly using the instructions.
-
The kit was not powered. Make sure the µBee, Pocket Bot, or other kit is correctly powered and turned on. Insufficiently charged batteries will also prevent successful programming.
-
The programmer is not connected properly to the kit. The 6-pin cable is a tight fit and requires a little bit of force to be properly connected to your kit or the programmer itself. Make sure it is seated fully snug in the receptacle. In some rare cases, your cable may have failed and needs to be replaced. This can happen since cables are often subjected to a lot of force.
-
The programmer is not properly powered. When connected to USB, you should see a green LED and red LED on your programmer both lit at the same time. If this is not the case, it is possible your USB port is not working correctly. Try another port, or another computer, to see if it receives power from those sources.
-
The wrong USB cable is used. USB cables can be either data cables or charging cables. Charging cables cannot be used for programming, and you must use a data cable. These are also called sync cables, etc. Any inexpensive USB cable not marketed as a data, sync, or high-speed data cable is likely only a charging cable, and will not work.
-
The USB cable is a data cable, but is damaged. This can happen over long-term use. Try a different USB cable, or a different USB port to rule out a problem with the cable. If the problem persists, please contact us.
-
The 6-pin programming cable is connected incorrectly. The Midnight Make Programmer has several ports. When connecting the 6-pin programming cable, be sure to plug it into the far end opposite the USB receptacle. See the image above in Section 2 (Connect the Programmer) for reference.
-
Try another kit, if you have one. If you have a different Midnight Make product, or more than one of the kind you are trying to program, try to program one of those other devices. This will reveal whether or not the problem is with the programmer or the kit.
- Disconnect everything and then re-connect. Sometimes devices can enter unstable states that prevent clean programming, but the fix is usually simple. Disconnect your programmer from your computer and your kit, and power cycle your kit. Then, reconnect everything and try again.
If you've tried these methods and still cannot successfully program your device, contact us. If we can't resolve your issue, we will issue a replacement programmer.
