Elegoo Smart Robot Car Β· V4 Β· Session 5

Your First Code

Today is a big one: you're going to put a program onto your robot all by yourself β€” then change one tiny thing in that program and watch the car behave differently. This is the moment you stop just using the robot and start programming it.

60 min Intermediate Ages 10+

You're about to actually program a robot πŸ€–

Take a deep breath β€” this is easier than it sounds, and we'll go one little step at a time. Nobody is expected to "just know" this. We're going to install one free program on your computer, plug the car in, send the car's program over the cable, and then make it yours by changing a single number. If anything goes sideways, that's totally normal β€” there's a whole "If something's not working" section near the bottom, and a teacher nearby. You can't break anything by trying. πŸ’ͺ

Here's the magic moment we're heading toward: change one number β†’ upload β†’ the robot does something new. Once you've done it once, you'll be able to change anything.

Already built your car? This lesson assumes your car is put together and working from Session 2. If it isn't built yet, grab a teacher β€” you'll want a finished car for today.

What you need

"Data" cable vs "charge-only" cable: some USB cables only carry power and can't send code. If your computer never "sees" the car later, the cable is the usual culprit β€” swap it for a different one.

So… what is code? πŸ’‘

Code is just a list of instructions the robot's brain follows, in order. That's really all it is. Think of a recipe ("crack the egg, then stir, then pour") β€” the robot reads its instructions top to bottom and does exactly what they say. The car you've been driving already has a program inside it. Today we're going to open that program, send a fresh copy onto the car, and then change one instruction so the car follows your rule instead.

A quick peek at the Arduino IDE β€” the program where code lives. Notice the setup part (runs once) and the loop part (runs over and over). Clip from an ELEGOO Starter-Kit "Install the IDE" lesson β€” that's a different kit, but the IDE is exactly the same idea (YouTube, ELEGOO Starter Kit).
Don't memorize anything. You do not need to understand every word on the screen. Today you only need to find one number and change it. Reading code comes later, a little at a time.

Let's do it, one step at a time πŸͺœ

1

Meet the program: the Arduino IDE

The program we type and send code with is called the Arduino IDE. "IDE" just means "the place where you write and upload code." It's free and made by the Arduino team. When it's open, it looks like this:

The Arduino IDE window with its toolbar buttons numbered and labeled: 1 verify, 2 upload, 3 new file, 4 open, 5 save, 6 serial monitor, 7 code writing area, 8 information bar
The Arduino IDE, with each button labeled. The two you'll care about today are the check mark (verify) and the arrow (upload) β€” from the ELEGOO V4 "Setting Up the Development Environment" guide (Windows).
The arrow is the magic button. That right-pointing arrow at the top is Upload β€” it sends your code onto the car. We'll press it in Step 5.
2

Install the Arduino IDE

On your computer, open a web browser and go to arduino.cc (the official site β€” https://www.arduino.cc/en/software). Download the version for your computer (Windows, Mac, etc.), then open the downloaded file and click through the installer β€” "I Agree," "Next," "Install." If a little window pops up asking to install driver software, say yes / Install β€” we want that.

It's free. Don't pay for anything. The download from arduino.cc is the real, free program. (You may see a "Just Download" button next to a donate button β€” "Just Download" is fine.)
Ask before installing. Some school or club computers need a teacher's password to install programs. Grab a grown-up before you start this step so you're not stuck waiting.
3

Help the computer "see" the car (the USB driver), then plug it in

Your car's brain talks to the computer through a tiny chip on its board. For the computer to hear it, it sometimes needs a little helper called the CH340 driver. The chip lives right here on the car's UNO board:

Close-up of the car's ELEGOO UNO R3 (Car V2.0) board with the USB-to-serial CH340 chip area highlighted in red near the USB port
The car's UNO board β€” the highlighted chip near the USB port is the USB-to-Serial (CH340) chip that lets the computer talk to the car. From the ELEGOO Smart Robot Car V4.0 ReadMeFirst (p.3).

Now grab the USB cable. Plug the small Micro-USB end into the car's board and the big end into your computer. On most newer computers the driver installs all by itself β€” give it a few seconds.

Most computers are automatic. On Windows 10/11, Mac, and Chromebooks the driver usually loads on its own. If your computer later can't find the car (no COM port in Step 4), that's when you install the CH340 driver by hand β€” there's a "CH340 driver software" folder in the kit's code download, and the "no COM port appears" tip in troubleshooting walks you through it.
4

Flip the switch to "Upload," then pick the board and port

This is the #1 most important step of the whole lesson, so go slow. On the car there's a little slide switch with two settings: "Upload" and "Upload-Cam" (sometimes shown as just "Upload" and "Cam"). To send code, it must be on Upload. Find it next to the USB port:

Diagram of the car's board showing the Upload-Cam switching button and the USB port, with a note to toggle the switch to Upload when uploading a program and to Cam when using the app
The Upload-Cam switching button and the USB port on the car's board. Slide it to "Upload" to send a program. From the ELEGOO Smart Robot Car V4.0 movement tutorial (DRV8835, p.10).

Now, in the Arduino IDE, tell it which robot you're talking to. Open the Tools menu and set two things:

  • Board β†’ choose "Arduino UNO" (it may say "Arduino/Genuino Uno" β€” same thing).
  • Port β†’ choose the one that looks like "COM3" / "COM6" (Windows) or /dev/cu.usbserial… (Mac). That's your car.
The Arduino IDE Tools menu open, showing Board set to Arduino/Genuino Uno and the Port submenu showing a COM port
Setting Tools β†’ Board β†’ Arduino/Genuino Uno and Tools β†’ Port β†’ COM… β€” from the ELEGOO V4 "Setting Up the Development Environment" guide (Windows).
Remember this: if the switch is on "Upload-Cam" instead of "Upload," the upload will fail β€” every time. When something goes wrong later, check this switch first!
5

Open the car's program and click Upload

In the kit's code download, find the car's program file. It's named SmartRobotCarV4.0.ino (an .ino file is an Arduino program). It usually lives in a folder like "02 Main Program / SmartRobotCarV4.0." Double-click it to open it in the Arduino IDE.

Now click the Upload button β€” the round arrow pointing right at the top. The computer will think for a few seconds (you might see it say "Compiling…" then "Uploading…"). When you see "Done uploading." at the bottom β€” and avrdude done. Thank you. β€” you did it! πŸŽ‰

The SmartRobotCarV4.0.ino program open in the Arduino IDE, and below it the green Done uploading message with avrdude done. Thank you.
The SmartRobotCarV4.0.ino program open in the IDE, and the "Done uploading" success message at the bottom. From the ELEGOO V4 "Setting Up the Development Environment" guide (Windows).
Nothing happened / it turned red? Don't worry β€” jump to "If something's not working" below. Nine times out of ten it's the switch (Step 4) or the Board/Port pick.
Keep the original safe. You just uploaded the original car program. Remember where SmartRobotCarV4.0.ino lives β€” if a change ever makes your car act weird, you can re-upload this exact file to put it back to normal.
6

Make it YOURS: change one number, upload again

Here's the moment. You're going to change a single number in the program, upload again, and watch the car act differently. Pick one of these:

  • πŸ›‘ Stop-distance: find a line that sets how close the car lets things get before it stops or turns away (often a number near words like distance). Make it bigger so the car keeps more space, or smaller so it gets braver.
  • 🏎️ Speed: find a motor speed value (Arduino motor speeds go from 0 to 255). Try lowering it so the car cruises slower and is easier to watch.

Change just that one number. Then click Upload (the arrow) again, wait for "Done uploading," set the car on the floor, and switch it on. Did it behave differently? You just programmed a robot! πŸš€

Golden rule: change ONE thing at a time. If you change five numbers at once and the car gets weird, you won't know which change did it. One number β†’ upload β†’ watch β†’ repeat. That's how real programmers work too.
Write down what you changed (line and old number) on a sticky note. Then if you want it back the way it was, you know exactly what to undo β€” or just re-upload the original SmartRobotCarV4.0.ino from Step 5.

If something's not working

"Upload failed" / the bar turned orange or red

Check these in order: (1) Is the car's slide switch on "Upload" (not "Upload-Cam")? This is the most common cause. (2) Is Tools β†’ Board set to Arduino UNO? (3) Is Tools β†’ Port set to your car's COM port? Fix any that are off and click Upload again.

No COM port shows up in the Port menu

The computer can't "see" the car yet. Try, in order: make sure the car is switched on and the cable is pushed in firmly at both ends; try a different USB cable (it must be a data cable, not charge-only); try a different USB slot on the computer. Still nothing? Install the CH340 driver from the kit's code download ("CH340 driver software" folder), then unplug and replug the car.

My car acts weird after I changed something

No problem β€” this is fixable and totally normal. Just re-upload the original SmartRobotCarV4.0.ino from Step 5 (switch on "Upload," click the arrow). That puts the car right back to how it started. Then change just one number again and watch what that single change does.

I can't find the SmartRobotCarV4.0.ino file

Look inside the kit's code download for a folder named something like "02 Main Program" or "SmartRobotCarV4.0," and open the file ending in .ino. If you only have a .zip, unzip it first. A teacher can point you to the club's copy if your download is missing.

It says "Done uploading" but the car doesn't move

The code is on the car β€” now check the car itself: is the battery charged and the power switch on? Set it on the floor (not held in the air), and after a change, give it a clear space to do its thing. If you uploaded a slower speed value, it might just be moving gently!

Level up πŸš€

You did the hard part β€” you programmed a real robot, and you saw your change come to life. Here's the best part: now you can change anything. Faster? Slower? Braver around obstacles? More careful? Try one more single-number change and see what happens. Then the big question: what should your robot do next? Dream something up β€” a new behavior, a trick, a challenge β€” and bring your idea to the club. That's where we'll head next. πŸ’‘