← Track
// teqstudy.embedded.course_02

Arduino &
Electronics

A hands-on bridge between theory and real hardware. Learners wire circuits, write Arduino sketches, read sensors, control outputs, debug mistakes, and finish with a working mini alarm system.

course toolkit
BoardArduino Uno R3 or compatible starter board
CodeArduino IDE, C/C++ basics, serial monitor
PartsLEDs, resistors, buttons, buzzer, potentiometer, sensors
CapstoneRoom-entry mini alarm with sensor input and status output
Course Progress
0%
Module 01

Setup, Safety & Hardware

Before a learner writes code, they need to know what is safe to plug in, what parts they are holding, and how Arduino differs from a Raspberry Pi.

🎯 Learning Objectives
  • Identify the Arduino board, USB port, power pins, digital pins, analog pins, and reset button.
  • Explain the difference between a microcontroller and a Linux computer.
  • Build a safe beginner parts kit and avoid wiring mistakes that can damage hardware.

Arduino

Runs one program directly on a microcontroller. Excellent for simple, reliable hardware control.

Raspberry Pi

Runs a full Linux operating system. Excellent for servers, cameras, dashboards, networking, and heavier software.

🧰 Starter Kit Checklist
PartWhy it matters
Arduino Uno or compatible boardThe main controller. The Uno layout is beginner-friendly and widely supported.
Breadboard + jumper wiresLets learners build circuits without soldering.
LEDs + 220Ω/330Ω resistorsFirst output circuit and current-limiting practice.
PushbuttonsFirst digital input component.
PotentiometerFirst analog input component.
Buzzer, LDR, temperature sensorSmall parts that make final projects feel alive.
⚠️
Safety ruleNever connect power directly to ground. That is a short circuit. Unplug USB before changing a messy circuit.
🧠 Quick Check
Why is Arduino a good beginner embedded board?
Module 02

Electricity Basics

Voltage, current, resistance, polarity, and ground explained with the exact level of depth a beginner needs before wiring components.

⚡ The Three Big Ideas
  • Voltage is electrical pressure. It pushes current through a circuit.
  • Current is the flow of electric charge. Too much current can burn components.
  • Resistance limits current. Resistors protect LEDs and input circuits.
🧮 Ohm's Law for Makers

You do not need to become an electrical engineer before building. You do need one formula:

Voltage = Current × Resistance
V = I × R

Example: if an LED circuit uses 5V and a safe current is around 0.02A, a resistor is used to keep current from running wild. In beginner Arduino LED circuits, 220Ω or 330Ω is a safe default.

💡
Ground is not optionalEvery circuit needs a shared reference point. If the Arduino and a component do not share ground, signals may behave randomly.
🧪 Lab: Trace a Circuit Before Building It
  1. Draw a battery, resistor, LED, and ground path on paper.
  2. Use arrows to show current flow from positive to ground.
  3. Label where the resistor protects the LED.
🧠 Quick Check
What does a resistor do in a basic LED circuit?
Module 03

Breadboards & LEDs

Learners assemble their first circuit, understand connected rows, and make an LED blink from a digital pin.

🍞 Breadboard Rules
  • Rows on each side of the center gap are connected in small groups.
  • The center gap separates the two halves of the board.
  • Power rails are used to distribute 5V and GND, but some breadboards split rails in the middle.
💡 First LED Circuit
  1. Connect Arduino GND to the breadboard ground rail.
  2. Place the LED across separate breadboard rows.
  3. Connect the LED's short leg to GND.
  4. Connect the LED's long leg through a 220Ω or 330Ω resistor to digital pin 13.
  5. Upload the Blink sketch.
const int ledPin = 13;

void setup() {
  pinMode(ledPin, OUTPUT);
}

void loop() {
  digitalWrite(ledPin, HIGH);
  delay(500);
  digitalWrite(ledPin, LOW);
  delay(500);
}
🔎
TroubleshootingIf the LED does not light, check polarity first. The longer LED leg is usually positive. Then check whether the resistor is actually in series.
🧠 Quick Check
What function tells an Arduino pin to output voltage?
Module 04

Arduino Sketches

A beginner-friendly introduction to Arduino code structure, variables, constants, setup, loop, comments, and compile errors.

setup()

Runs once when the board powers on or resets. Use it for pin modes and starting tools like Serial.

loop()

Runs forever after setup. Use it for repeated behavior: read inputs, make decisions, control outputs.

🧱 Sketch Anatomy
const int ledPin = 9;  // constant pin number
int blinkDelay = 250;  // variable value

void setup() {
  pinMode(ledPin, OUTPUT);
}

void loop() {
  digitalWrite(ledPin, HIGH);
  delay(blinkDelay);
  digitalWrite(ledPin, LOW);
  delay(blinkDelay);
}
🛠️ Common Compile Errors
ErrorLikely cause
expected ';'Missing semicolon at the end of a statement.
not declared in this scopeMisspelled variable or variable created in the wrong place.
expected '}'Missing closing brace after setup, loop, or an if statement.
🧪 Lab: Custom Blink Pattern

Change the code so the LED blinks two fast pulses, waits one second, then repeats. This teaches sequence thinking and timing.

🧠 Quick Check
Which function repeats forever on an Arduino?
Module 05

Digital Input

Buttons teach learners the core embedded pattern: read an input, decide what it means, then control an output.

🔘 Buttons Are Not Magic

A pushbutton is a switch. When pressed, it connects two sides of a circuit. When released, it opens the circuit. The Arduino needs a clean HIGH or LOW signal, not a floating unknown signal.

Use INPUT_PULLUP firstArduino can enable an internal pull-up resistor. That means the input reads HIGH by default, and LOW when the button connects the pin to ground.
const int buttonPin = 2;
const int ledPin = 13;

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  int pressed = digitalRead(buttonPin) == LOW;
  digitalWrite(ledPin, pressed ? HIGH : LOW);
}
🧪 Lab: Press-to-Light
  1. Wire one side of a button to digital pin 2.
  2. Wire the other side to GND.
  3. Upload the sketch above.
  4. Confirm the LED lights only while the button is pressed.
🧠 Quick Check
With INPUT_PULLUP, what does a pressed button usually read?
Module 06

Analog Input

Analog input turns real-world variation into numbers. This is the doorway to knobs, light sensors, temperature sensors, and responsive devices.

🎚️ What analogRead() Returns

On classic Arduino Uno-style boards, analog input reads a value from 0 to 1023. A potentiometer is the easiest first analog sensor because learners can turn it by hand and see the value change immediately.

const int knobPin = A0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  int value = analogRead(knobPin);
  Serial.println(value);
  delay(100);
}
🧠 Mapping Values

Raw sensor values are rarely the final behavior. The maker's job is to map a reading to an output.

int sensor = analogRead(A0);
int brightness = map(sensor, 0, 1023, 0, 255);
🧪 Lab: Knob-Controlled Brightness

Use a potentiometer on A0 to control LED brightness on a PWM pin. This connects analog input to visible output.

🧠 Quick Check
What kind of value does analogRead(A0) return on a typical Uno?
Module 07

PWM & Output Control

Pulse-width modulation makes digital pins act like variable outputs for brightness, simple motor speed control, and buzzer effects.

🌈 What PWM Means

An Arduino digital pin can only be ON or OFF, but PWM switches it on and off very quickly. Changing how long it stays on changes the average power a component receives.

const int ledPin = 9;

void setup() {
  pinMode(ledPin, OUTPUT);
}

void loop() {
  for (int level = 0; level <= 255; level++) {
    analogWrite(ledPin, level);
    delay(8);
  }
}
⚙️
Motors need driversDo not power motors directly from an Arduino pin. Use a motor driver or transistor circuit because motors draw more current than a pin should supply.
🧪 Lab: Fade an LED

Wire an LED to a PWM-capable pin through a resistor, then fade it smoothly from off to bright.

🧠 Quick Check
Which Arduino function is used for PWM output?
Module 08

Serial Debugging

Learners stop guessing and start inspecting. Serial output is the beginner's first embedded debugging tool.

🧪 Why Serial Matters

When a circuit acts wrong, beginners often stare at wires and hope. The Serial Monitor lets them print what the board is reading and what decisions the code is making.

void setup() {
  Serial.begin(9600);
}

void loop() {
  int light = analogRead(A0);
  Serial.print("Light value: ");
  Serial.println(light);
  delay(250);
}
🔍 Debugging Checklist
  1. Print sensor values before using them in logic.
  2. Print button state to confirm wiring.
  3. Print which branch an if statement enters.
  4. Reduce delays while debugging so feedback feels instant.
🧪 Lab: Debug a Broken Button

Intentionally wire a button, print its state, then fix the wiring or code until the serial output changes exactly when pressed.

🧠 Quick Check
What is the Serial Monitor best for in beginner projects?
Module 09

Sensors & Modules

This module moves from single components to small modules: light sensing, sound output, distance sensing, and status indicators.

📡 Sensor Pattern

Most Arduino sensor projects follow the same loop:

read sensor → clean value → compare threshold → control output → print debug info

LDR / Photoresistor

Detects light level. Great for night-light projects and alarms.

Ultrasonic Sensor

Measures distance using sound pulses. Great for parking assistants and motion triggers.

Buzzer

Makes sound for alarms, timers, and feedback.

RGB LED

Shows device state with color: armed, warning, triggered, idle.

🚦 Threshold Logic
int light = analogRead(A0);

if (light < 300) {
  // room is dark
} else {
  // room is bright
}
🧪 Lab: Smart Night Light
  1. Read an LDR value on A0.
  2. Print the raw value to Serial.
  3. Choose a threshold.
  4. Turn an LED on automatically when the room gets dark.
🧠 Quick Check
What is a threshold in a sensor project?
Module 10

Capstone: Mini Room Alarm

The final build combines digital input, analog input, PWM output, serial debugging, and sensor thresholds into a portfolio-ready beginner device.

🏁 Project Goal

Build a small room-entry alarm that can be armed with a button, triggered by a sensor, and communicate its state with an LED and buzzer.

📦 Required Parts
  • Arduino Uno or compatible board
  • Breadboard and jumper wires
  • Pushbutton
  • LED or RGB LED + resistors
  • Buzzer
  • LDR or ultrasonic sensor
🧠 System States
StateBehavior
IdleSystem is not armed. LED is off or dim.
ArmedButton has armed the system. LED shows ready state.
TriggeredSensor crosses threshold. Buzzer sounds and LED flashes.
ResetButton press returns the alarm to idle.
// Capstone starter structure
bool armed = false;
bool triggered = false;

void setup() {
  Serial.begin(9600);
  // configure pins here
}

void loop() {
  // 1. read button
  // 2. read sensor
  // 3. update armed/triggered state
  // 4. control LED and buzzer
  // 5. print debug info
}
🚀 Ship-It Checklist
  1. Draw the wiring diagram.
  2. Write the final sketch with comments.
  3. Add a troubleshooting section.
  4. Record a short demo video.
  5. Write a README explaining what the device does and how to rebuild it.
🧠 Final Check
What makes this capstone stronger than a random LED exercise?