CanSat Tutorials

Tutorial 1 of 9 · Getting started

Set up the Arduino IDE and connect your Uno

Install the software, plug the board in, and prove the whole chain works before you write a single line of your own code.

Tutorials 1 2 3 4 5 6 7 8 9

This one is all setup. Nothing is soldered, nothing can break, and by the end you will have made an LED on the board flash. That matters more than it sounds: it proves your laptop, your cable, your board and the software all talk to each other. Every problem after this is a problem with your code, not your kit.

You needNotes
An Arduino Uno R3 or a cloneClones are fine and much cheaper. They may need an extra driver, see step 1.
A USB cable that carries dataUno R3 uses the big square USB-B plug. Some cables only carry power, and that is the usual reason a board never shows up.
A laptopWindows, macOS or Linux. A school laptop may block installing software, see the note below.
About twenty minutesMost of it waiting for the download.
If your school locks down software

The Arduino Cloud Editor runs in a browser at app.arduino.cc and needs only a small plugin to reach the USB port. Everything in these tutorials works there too. If even that is blocked, ask whoever runs IT for the desktop IDE by name: it is free, open source and widely used in schools.

Step by step

From nothing to a blinking LED

  1. Install the Arduino IDE

    Download it from arduino.cc/en/software. Take version 2.x, the current desktop one. Install it and open it.

    If your board is a clone, it probably uses a CH340 or CH9102 USB chip instead of the original. Windows usually finds the driver itself now. If it does not, search for CH340 driver plus your operating system. On macOS and Linux it normally works with no driver at all.

  2. Plug the board in

    Connect the USB cable. A green LED marked ON should light and stay lit. If nothing lights up, try a different cable before you try anything else.

  3. Tell the IDE what you have plugged in

    The IDE has no way of knowing. Two menus to set:

    Tools › Board › Arduino AVR Boards › Arduino Uno, then Tools › Port and pick the one that appeared when you plugged in. On Windows it looks like COM3, on macOS /dev/cu.usbmodem1101, on Linux /dev/ttyACM0 or /dev/ttyUSB0. Unplug the board and look at the list again if you are not sure which is which: the one that disappears is yours.

  4. Open an example that already works

    File › Examples › 01.Basics › Blink. Do not type anything yet. Starting from code that is known to work means that if it fails, the fault is in your setup and not in your typing.

  5. Verify, then upload

    The tick button (Verify) compiles the sketch on your laptop and tells you about mistakes. The arrow button (Upload) compiles it and then sends it to the board. Press the arrow.

    Two small LEDs marked TX and RX will flicker while it transfers. Then the LED marked L next to pin 13 starts blinking: one second on, one second off.

Under the bonnet

What actually happened when you pressed upload

Pressing Upload starts a chain of four things. When an upload fails, it fails at one of them, so it helps to know what they are.

StageWhat happens
CompileYour laptop turns the sketch into machine code for the ATmega328P chip on the Uno. Spelling mistakes and missing semicolons stop here, and you get a red error.
ResetThe IDE pulses the board's reset line over USB. The board restarts into a small program called the bootloader.
TransferThe bootloader listens on the serial port and writes the machine code into the chip's flash memory. That is the TX and RX flicker.
RunThe board restarts and runs your code. It keeps it until you upload something else.
Why this matters for a CanSat

The program lives on the board, not on your laptop. Once uploaded, the board runs it every time it gets power, with no computer attached. That is why a microcontroller can be sealed inside a can, fired to 400 metres, and still know what to do on the way down.

The tools

The five parts of the IDE you will actually use

You will use five things in the IDE and ignore the rest for now.

ControlWhereWhat it does
VerifyTick, top leftCompiles without uploading. Fast way to check for typing mistakes.
UploadArrow, top leftCompiles and sends to the board. Ctrl/Cmd + U.
Serial MonitorMagnifier, top rightA window showing text the board sends back. Tutorial 3 lives here.
Board and portDropdown, top centreWhat you set in step 3. Check it every time you plug in.
Library ManagerBooks, left sidebarInstalls code other people wrote, such as the sensor driver in tutorial 7.

Your sketches are saved in a folder called Arduino inside your documents folder, one folder per sketch. Give them names with no spaces, and keep the old version when you change something that works: descent_log_v1, descent_log_v2. You will want to go back at some point, and your CanSat report will want to show how the software developed.

Troubleshooting

If it does not work

Almost every first time problem is in this table.

What you seeWhat to check
No port in the Tools › Port menuThe cable is charge only, the board is not powered, or the clone's USB driver is missing. Try another cable first.
avrdude: stk500_recv(): programmer is not respondingWrong board or wrong port selected. Also caused by anything wired to pins 0 or 1, which the USB link uses.
Permission denied on the port, LinuxYour user is not in the dialout group. Add it, then log out and back in.
Upload succeeds but nothing blinksLook for the LED marked L, not the one marked ON. On a few clones the built-in LED is on a different pin, so try an external LED on pin 13.
The board keeps resettingUsually a power problem: a sensor or motor drawing more current than the USB port will give. Unplug everything except the board.
Red text mentioning a missing libraryYou opened a sketch that needs something installed. Library Manager, search, install.
Read the red text

Compiler errors look unfriendly, but they almost always name the file and the line number. Fix the top one first, then press Verify again. The errors below it are often just knock-on effects, and they disappear on their own.

Now change it

Change one thing at a time, upload, and watch what the board does.

  1. Change both 1000 values to 200 and upload. Then 50. Then 5. At what point does it stop looking like blinking?
  2. Make the LED spend longer off than on. Which number did you change, and does the pattern tell you which line does what?
  3. Upload the sketch, then unplug the USB cable and power the board from a USB phone charger or a power bank. What does that tell you about where your program is stored?
  4. Find the Blink sketch folder on your laptop. Save a copy under your own name, change something, and keep both.
  5. Make the LED blink the letter S in Morse code: three short flashes. Then try S O S.