- Plug the USB cable into both the Arduino board and the computer.
- Open the Arduino software on the computer.
- Maximize the Arduino software window.
- In the menu bar, go to Tools>Port> and click the COM# with “Arduino/Genuino Uno” next to it.
STEM Connections
Unlike the LED Blink activity where existing code was modified to make the LED blink in different ways, this activity will require you to write code from start to finish. The first step in writing new code is to open a new programming window.
Servos do not rotate on their own. Mechanical engineers connect computers and other devices to Servos to control their movement. You will be using the computer and the Arduino board for this.
Without a computer program, the Arduino board is not able to control the movement of a Servo. You will be using the Arduino software to send computer programs to the Arduino board. To make sure the Arduino board can receive the programs, you first have to indicate in the Arduino software which COM port you will be using.
The sketch has code already
- To get a new Arduino sketch window, go to File>New
No COM# with (Arduino/Genuino Uno)
- Check that the USB is plugged all the way in to both the Arduino board and the USB port on the computer.
- Click out of menu bar and try again (sometimes it takes a while for your computer to recognize a new device).
- Try unplugging and re-plugging in the USB cable
- Try restarting the Arduino software
- Try a new Arduino Uno board
- Try a different USB cable
- Try a different computer
- There are two main coding experiences for programmers. One is taking existing code and modifying it for your current specific needs and the other is to write code completely from start to finish. This Sservo activity is like the latter.
- If you are completing the LED Blink and Servo activities on the same day, the correct port should already be selected, but it’s good practice to always remember this step.
- Any time you connect something (whether it’s an external mouse, keyboard, etc.) to your computer, your computer assigns it a unique COM#, or like a virtual door number, to know where to send different pieces of information. Connecting your Arduino board to your computer is no different and the information we are wanting to make sure the Arduino board receives from the computer is the uploaded code.
- Another way to look at it is to think of writing code for Arduino is a lot like texting. Ask the students “how many of you have ever texted before?” This should be a very relatable analogy. Next, ask your students, “what is the first thing you do when you want to text somebody?” When you send a text, the first thing you need to do is open the Messages App. When you write code for Arduino, the first thing you need to do is open the Arduino software.
- Keeping with the texting analogy, ask, “what would you do next if you were texting?” While many students will tell you to start writing your text, the next thing you would do is select the person you want to send your message to. When writing code, the next step is to select the port where you will upload your code.
- One difference between texting and uploading code is a text allows you to send whether you have grammatical errors or not, while code will not upload if it does not compile properly.
- At this point, if your students are working in pairs, tell them that they will share the coding responsibility, with one partner being responsible for the first half of the code and the second partner responsible for the second half. Whoever is not typing is checking the work of their partner as they go along.