The Arduino is a very popular microcontroller platform for hobbyist electronics and citizen-science projects and is used by many members of the Public Lab community.
This activity walks you through the process of connecting an Arduino to your computer and uploading a simple example program. This is always a good thing to do before you start working on a new Arduino project.
If you verify that the board is working before you get started it is easier to troubleshoot any problems you find yourself having later on down the road.
We will use the Arduino IDE to program our Arduino and to read data from it. You can download it here.
If you are using one of the cheaper clone Arduino boards you will probably also need to install the CH430 drivers. You can find them here.
The Arduino uses a USB cable to connect to your PC. We will use this USB connection to send the program that we want the Arduino to run from our computer and to allow the Arduino to send data back to our computer.
The Nano and the Uno have different form-factors and use different styles of USB cable but they both have a built-in USB port for programming and charging that you can plug a cable into.
The next thing we want to do is to upload and run an example program from the Arduino IDE so that we can see that the board is working and our program is running.
If you are having trouble getting your first test program uploaded to the board, the Arduino webpage has a long troubleshooting section that you can look at. The most likely cause of trouble, though, is that your computer just isn't seeing the Arduino through the USB port.
You may get an error message when you press the upload button (usually it will say something like "An error occurred while uploading the sketch" or "Problem uploading to board.")
If you get an error like this, you will probably solve it by performing the following steps:
- Check to make sure that your Arduino has power. There should be a power indicator light on the board that should be ON. If it is not on that means your board isn't getting power over USB. Try switching USB cables (because the cable might be broken) and try all of the different USB ports on your computer.
- If the board is getting power but you still have an error message, you probably don't have the correct port selected. Go to the Tools->Port menu and try to switch to a different COM port. Try them all and try uploading your sketch with each one.
- If your board is getting power and you've tried all of your available ports and you still get these errors when you try to upload your sketch, you should try unplugging the board and plugging it back in again, testing all the available USB ports on your computer as you do so.
This will solve the vast majority of your problems. If this doesn't help, you should have a look at the Arduino troubleshooting guide.