Robotics & Arduino
Basics

From onboard to an external LED.

What is an LED?

An LED (Light Emitting Diode) is a small electronic component that makes light.

It lights up when current flows through it in the correct direction.

LED legs: long is positive, short is negative The LED has two visibly different leg lengths. The long leg on the left is the positive anode, connected to pin 13 through a resistor. The short leg on the right is the negative cathode, connected to ground. LONG LEG Positive (+) SHORT LEG Negative (−) Anode Cathode
Long leg = positive (+). Short leg = negative (−).

Remember our water wheel?

  • The wheel works in one direction; the LED also has a correct direction.
  • Voltage is like water pressure; current is like water flow.
  • Too much current can damage the LED.
  • A resistor is like a narrow pipe: it limits the flow of current.

Connect a regular LED.

Disconnect USB while wiring.

D13220 Ω resistorLong leg: positive (+) Short leg: negative (−) GND

The onboard resistor protects only the onboard LED. Our external LED needs its own resistor, even on pin 13.

Make the pin number explicit.

const int LED_PIN = 13;

On the Uno, LED_BUILTIN already means pin 13. Keep the rest of the touch-sensor code unchanged.

Reconnect USB → Check → Upload.
Touch the sensor and watch your LED.

The onboard LED will follow along too.