🤖 Intro to Robotics — Arduino Notes
1. Arduino Basics
What is Arduino?
Arduino is an open-source electronics platform used to build and program electronic/robotic projects.
An Arduino board contains a microcontroller that runs your program.
Arduino was originally designed to make electronics/prototyping easier and more accessible, including for artists and beginners.
Arduino program = Sketch
An Arduino program is called a sketch.
A sketch is the code that tells the Arduino what to do.
Arduino code is based on C/C++.
IDE
IDE = Integrated Development Environment
Software used to write, compile, and upload your Arduino code.
The Arduino IDE provides the tools needed to work with your sketch.
2. Important Arduino Functions ⭐
setup()
Runs once when the Arduino starts/reset.
Used for things that only need to happen once, such as setting pin modes.
void setup() {
}loop()
Runs repeatedly after
setup()finishes.This is where you put the main functionality of your robot/project.
void loop() {
}Easy way to remember:
setup = once
loop = over and over 🔄
3. GPIO
GPIO = General Purpose Input/Output
GPIO pins allow the Arduino to:
Input: receive information from a component/sensor.
Output: send a signal to control a component.
Think:
Input → Arduino → Output
Example:
Button → Arduino → LED
4. Arduino Pins
pinMode()
Used to define/configure what a digital pin will do.
Syntax:
pinMode(pin, mode);Common modes:
INPUT
OUTPUT
INPUT_PULLUPExample:
pinMode(13, OUTPUT);This tells the Arduino:
“Pin 13 is going to be an output.”
digitalWrite()
Used to set a digital output HIGH or LOW.
digitalWrite(pin, HIGH);
digitalWrite(pin, LOW);HIGH→ output voltage is approximately the board's HIGH voltage (5V on a typical Uno)LOW→ approximately 0V
Example:
digitalWrite(13, HIGH);→ Turns the output on.
digitalWrite(13, LOW);→ Turns the output off.
5. delay()
delay(milliseconds)
Pauses the program for a specified amount of time.
delay(1000);1000 milliseconds = 1 second
delay(500);500 milliseconds = 0.5 seconds
⚠ Your note says “delay, seconds,” but Arduino's delay() uses milliseconds, not seconds.
Example
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);Meaning:
Turn output ON
Wait 1 second
Turn output OFF
6. LED 💡
LED = Light-Emitting Diode
An LED is a diode that produces light when current flows through it in the proper direction.
Diode
Allows conventional current to flow primarily in one direction.
The direction matters when connecting an LED.
LED polarity
An LED has two sides:
Anode (+) → positive side
Cathode (−) → negative side
Your drawing is showing the important idea:
Current flows from higher voltage toward lower voltage through the circuit (conventional current).
7. Resistor
A resistor limits the amount of current flowing through a circuit.
Why do we use one with an LED?
An Arduino pin should not directly drive an LED without appropriate current limiting.
A resistor limits the current so the LED and Arduino pin aren't subjected to excessive current.
Your notes use:
330 Ω resistor
That's a common value for an Arduino LED circuit.
8. Ohm's Law ⭐
The formula:
V=IRV = IR
Where:
V = Voltage (volts)
I = Current (amps)
R = Resistance (ohms, Ω)
You can rearrange it:
I=VRI = \frac{V}{R}
or
R=VIR = \frac{V}{I}
Example from your notes
If:
Arduino output = 5V
Resistor = 330 Ω
LED voltage drop ≈ 2V
Then:
VR=5V−2V=3VV_R = 5V - 2V = 3V
So:
I=3330I = \frac{3}{330}I≈0.0091AI \approx 0.0091A
or about:
9.1 mA
That's within a reasonable range for an Arduino LED circuit.
9. Arduino Output Current
Your notes say:
“Typical output pin: 10–15 mA with 5V”
The important concept to know is:
An Arduino digital pin provides a limited amount of current.
20 mA is the commonly specified maximum DC current per I/O pin on an Arduino Uno.
You generally design circuits so you don't need to draw the maximum.
So don't memorize “10–15 mA” as a universal Arduino rule—it can depend on the board and circuit.
10. Voltage, Current & Ground ⚡
Voltage
Voltage is the electrical potential difference that drives current through a circuit.
Current
Current is the flow of electric charge.
Ground (GND)
Ground provides the circuit's reference/return point.
In a basic Arduino circuit, components often connect back to an Arduino GND pin.
Easy way to think about it:
5V → component → GND
The circuit needs a complete path for current to flow.
11. ESD ⚠
ESD = Electrostatic Discharge
This is the sudden discharge of static electricity.
It can damage sensitive electronic components.
Your notes mention that components can be sensitive to ESD, so be careful when handling electronics.
12. Arduino Board Safety
Your note says:
“Arduino board → don't use pin 0 and 1”
The important reason is that pins 0 and 1 on an Arduino Uno are associated with serial communication:
Pin 0 = RX
Pin 1 = TX
They're not inherently forbidden, but using them for other things can interfere with serial communication, USB communication, or uploading sketches.
For beginner projects, it's often easier to avoid pins 0 and 1 unless you specifically need them.
13. Communication / Serial
Your notes mention:
“0 and 1 → communication”
Correct.
On an Arduino Uno:
RX (0) = receive serial data
TX (1) = transmit serial data
These pins are commonly used for serial communication with a computer or other devices.
14. Arduino Programming Basics
Arduino statements generally end with a semicolon ;.
Example:
digitalWrite(13, HIGH);
delay(1000);A comment begins with:
//Example:
// Turn the LED on
digitalWrite(13, HIGH);Anything after // on that line is treated as a comment and isn't executed.
15. LCD
LCD = Liquid Crystal Display
An LCD is a display that can show information such as:
Text
Numbers
Sensor readings
Messages
It is an example of an output device because the Arduino sends information to it for the user to see.
16. Algorithms
Algorithm
An algorithm is a set of ordered steps used to solve a problem or accomplish a task.
Think:
Algorithm = recipe for solving a problem
The order matters because changing the order of steps can change the result.
🧠 HIGH-PRIORITY THINGS TO MEMORIZE
If you have a quiz, I'd especially know these:
Term | Meaning |
|---|---|
Arduino | Microcontroller/electronics platform |
Sketch | Arduino program |
IDE | Integrated Development Environment |
GPIO | General Purpose Input/Output |
| Runs once |
| Runs repeatedly |
| Sets a pin's mode |
| Sets digital output HIGH/LOW |
| Pauses program; uses milliseconds |
LED | Light-Emitting Diode |
Diode | Mainly allows current in one direction |
Resistor | Limits current |
Ohm's Law |
|
ESD | Electrostatic Discharge |
GND | Ground/reference/return connection |
LCD | Liquid Crystal Display |
Algorithm | Ordered steps for solving a problem |
RX / TX | Serial receive / transmit |
The Arduino flow you should be able to explain:
Write sketch → Compile → Upload → Arduino runs setup() → Arduino repeatedly runs loop()
And remember:
setup() = ONCEloop() = FOREVER 🔄pinMode() = WHAT IS THIS PIN?digitalWrite() = WHAT SHOULD THE PIN OUTPUT?delay() = WAIT HOW LONG?