Sub topic 5
What the USB cable provides
This chapter assumes you know basic voltage, current and resistance, that you can upload a sketch from the Arduino IDE, and that you know the setup()/loop() structure. The reference board is the Arduino Uno R3. The Uno's USB-B port is not just a power inlet. It carries power, a data link to your computer, and a reset signal, and each of the three behaves differently.
Four wires, three jobs
A USB cable has four conductors, and the board uses them as follows:
| Conductor | Name | Use on the Uno |
|---|---|---|
| Red | VBUS (+5 V) | Powers the board, through a protective fuse |
| White | D- | Data to the USB bridge chip |
| Green | D+ | Data to the USB bridge chip |
| Black | GND | Common ground reference |
The data lines do not connect to the main microcontroller. On the Uno R3 they go to a second chip, the ATmega16U2, which acts as a USB-to-serial bridge. That chip converts between USB packets and the plain TX/RX serial signals that the main chip (the ATmega328P) understands. The next chapter covers the bridge in detail. Here the focus is on what arrives at the board and what limits it.
Power from USB
How VBUS reaches the 5V pin
VBUS passes through a resettable fuse (a polyfuse) rated at 500 mA. After the fuse, a power selector circuit decides whether the board runs from USB or from the barrel jack/VIN input. If an external supply of roughly 6.6 V or more is present, the board switches to it automatically. Otherwise it uses USB. The resulting regulated rail appears on the 5V pin, and the 3.3 V regulator is fed from it.
Because USB feeds the 5V rail directly, with no regulator in between, the rail is only as good as the port. A port at 4.75 V gives you 4.75 V.
How much current you can draw
USB defines current limits by port type. The board's fuse caps what you can draw no matter how strong the source is.
| Source | Typical limit | Notes |
|---|---|---|
| Computer USB 2.0 port | 500 mA after the bridge identifies itself | 100 mA before identification |
| Computer USB 3.x port | 900 mA | The Uno's fuse still limits it to about 500 mA |
| Unpowered hub | 100 mA per port | Often too little for the Uno plus a few parts |
| Wall charger | 1 A or more | Power only, with no data and no upload |
The fuse is not a precise cutoff. It has a hold current and a trip current, and the trip current is higher than the hold current. If you draw more than the hold current, it heats up, its resistance rises, and the voltage on the 5V rail sags. When you unplug the load and the cable, it cools and resets.
What fits in the 500 mA budget
The board itself uses roughly 50 mA. Each LED with a resistor takes 5 to 20 mA. A small hobby servo can take hundreds of milliamps when it starts moving. A motor, a strip of addressable LEDs or a relay bank will exceed the budget quickly. Power those from a separate supply and join its ground to the Arduino's GND. Do not draw their current through the 5V pin.
Data: more than serial text
Enumeration and the port name
When you plug in the cable, the operating system asks the bridge chip what it is. This is called enumeration. The Uno R3 identifies itself as a serial device, and the OS creates a port. The name depends on the OS and the bridge chip:
- Windows:
COM3,COM4and so on, with the number assigned by Windows. - macOS:
/dev/cu.usbmodem14101, where the number varies with the USB port. - Linux:
/dev/ttyACM0for the Uno's 16U2. Many clones use a CH340 or CP2102 bridge instead and show up as/dev/ttyUSB0.
If no port appears, the first suspect is the cable. Many cables are charge-only and have no data conductors at all. A charge-only cable will power the board, so the power LED lights and an old sketch keeps running. That makes the fault easy to misread as a driver or IDE problem.
The cable is also the reset line
The bridge chip's DTR output connects to the 328P's RESET pin through a 100 nF capacitor. When a program on your computer opens the serial port, DTR drops briefly, and the capacitor turns that edge into a short reset pulse. This is the mechanism behind two behaviors you will notice:
- The IDE can start an upload without you pressing the reset button. The reset starts the bootloader, which waits briefly for new code.
- Opening the Serial Monitor restarts your sketch. The board runs
setup()again every time the monitor connects.
The sketch below makes the restart visible. It prints a banner once in setup() and then reports uptime. If you open and close the Serial Monitor, the uptime goes back to zero each time.
void setup() {
Serial.begin(9600);
Serial.println("Sketch started (setup ran)");
}
void loop() {
Serial.print("Uptime: ");
Serial.print(millis() / 1000);
Serial.println(" s");
delay(1000);
}Measuring the rail you actually have
You can estimate the supply voltage without a multimeter. The ATmega328P can measure its own internal 1.1 V reference against VCC. Since the reference is fixed, the ratio tells you VCC. This sketch is specific to the 328P (the Uno and classic Nano) and gives an approximate answer, because the 1.1 V reference itself varies by a few percent between chips.
long readVccMillivolts() {
// Select VCC as reference and the internal 1.1 V band-gap as the input
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
delay(2); // let the reference settle
ADCSRA |= _BV(ADSC); // start one conversion
while (bit_is_set(ADCSRA, ADSC)) { }
int raw = ADC;
return 1125300L / raw; // 1.1 V * 1023 * 1000
}
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.print("VCC: ");
Serial.print(readVccMillivolts());
Serial.println(" mV");
delay(1000);
}Run it on USB and then through the barrel jack. A healthy USB port reads somewhere around 4.7 to 5.2 V. A value that drops when you switch on a motor or servo means the supply is sagging under load. The same drop also shifts every analogRead() conversion that uses the default reference. This is why a sensor reading can change when something unrelated switches on.
Common mistakes
- Using a charge-only cable. The board powers up, but no port appears and uploads fail.
- Powering motors from the 5V pin while on USB. The load exceeds the fuse's hold current, and the board resets or stalls.
- Plugging into an unpowered hub. The 100 mA limit causes brownouts.
- Leaving something on pins 0 and 1. These are the TX and RX lines shared with the bridge. A wire or shield connected to them can block uploads or corrupt serial output.
- Expecting the monitor to attach without a restart. If your sketch holds state that matters, such as a motor position, the reset from opening the monitor will clear it.
- Back-powering through the 5V pin. Feeding 5 V into the pin while USB is also connected bypasses the fuse and selector. Use one source at a time unless you know the circuit.
Exercise
A student connects an Uno to a laptop and the power LED lights, but no serial port appears in the IDE and the sketch from last week keeps blinking. What is the most likely cause, and how can they confirm it?
Show answer
The cable is most likely charge-only, with no D+ and D- conductors. It supplies VBUS, so the board powers on and runs the sketch already stored in flash, but the computer cannot enumerate the bridge chip. They can confirm by swapping in a cable known to carry data, such as the one that came with a phone's file transfer, and checking whether a port appears.
Exercise
You run the uptime sketch, open the Serial Monitor, and see "Uptime: 12 s". You close and reopen the monitor. Why does it start again from "Sketch started" with an uptime near 0?
Show answer
Opening the serial port makes the host pull DTR low. The bridge chip passes that edge through a 100 nF capacitor to the 328P's RESET pin, which resets the microcontroller. The reset restarts the sketch, so setup() runs again and millis() starts from zero.
Exercise
Your project has an Uno on USB and a hobby servo powered from the 5V pin. When the servo moves, the board resets. Give two ways to fix this.
Show answer
Power the servo from its own external 5 V supply and connect that supply's ground to the Arduino's GND. Alternatively, power the whole board from the barrel jack or VIN with an adequate supply, so the load does not run through the 500 mA USB fuse. Adding a bulk capacitor across the servo supply helps with startup spikes but does not replace a stronger supply.