Robots Atlas>ROBOTS ATLAS

Arduino for Beginners · Digital Inputs and Outputs

pinMode() and digitalWrite() — controlling an LED

Digital Inputs and Outputs

Introduction

The first step in digital electronics with Arduino: lighting an LED. This lesson dissects two fundamental functions — pinMode(), which sets a pin direction (input/output), and digitalWrite(), which drives a pin to HIGH (5V) or LOW (0V). We cover logic levels, the current limits of Arduino Uno pins (~20mA typical, 40mA absolute maximum), sizing a current-limiting resistor with Ohm's law, the structure of an LED (anode/cathode), and the built-in LED on pin 13 (LED_BUILTIN). Finally we assemble the classic blink sketch in the setup()/loop() structure.