Robotics & Arduino
Lesson 2 · Refinement
Lesson
index.
Lesson 2 — cover
Our goal
Agenda
Lesson index
Recap — the foundations
Electricity — remember the wheel?
Same pins, different jobs
An input pin — our voltmeter
Arduino — who decides?
Code — remember and decide
Code structure — DECLARE, INIT, RUN, LOGIC
The IDE — write, send, listen
LDR — task failed successfully
Meet the LDR
Connect the LDR — build the code
Watch the readings — the first test
Fail number 2 — why zero?
Voltage and current — the water analogy
Resistors — like a tap
Before and after the tap
How can we fix it? Choke the pipe
The voltage divider
Third time’s the charm — add the resistor
Quick recap, a break, and a three-LED challenge
LDR theory — photons and the band gap
Potentiometer — control the divider
From fixed resistors to a potentiometer
How does a potentiometer work?
Poetry in motion — electric potential
Do It Yourself — readings and LEDs
Answers, GPT Generated
Inside the servo
Fast-Forward — Connecting the scales
The motor — power, speed, and direction
Interactive H-bridge — four switches, two directions
MOSFETs — control the switches with code
Put it together — position-control pseudocode
Meet the servo — motor, gears, controller, and pot
Connect the ideas
Extra depth - optional — video links
Optional — header files and the Morse component
Let’s spin — servo code and loops
Let’s spin! Test and calibrate
The shared code — INCLUDE, DECLARE, INIT
Basic movement, while, for, and back-and-forth flags
Your first independent robot
Follow the light — the assignment
GPT SOLUTION — logic, pseudocode, and Arduino code