A.1 Key Formulas
| Topic | Formula |
|---|---|
| Current | I = Q / t |
| Ohm's law | V = I R |
| Power | P = V I = I²R = V²/R |
| Series resistors | R = R1 + R2 + ... |
| Parallel resistors | 1/R = 1/R1 + 1/R2 + ... |
| Voltage divider | Vout = Vin × R2 / (R1 + R2) |
| LED resistor | R = (Vsupply − VLED) / ILED |
| Capacitor | Q = C V; τ = R C |
| Transformer | Vs / Vp = Ns / Np |
| ADC to volts (UNO) | V = reading × 5 / 1023 |
| PWM average voltage | V = 5 × (value / 255) |
| Ultrasonic distance | d (cm) = time (µs) × 0.0343 / 2 |
| Servo pulse | 1 to 2 ms every 20 ms |
A.2 Arduino Function Cheat Sheet
| Function | Use |
|---|---|
pinMode(pin, mode) | INPUT, OUTPUT, INPUT_PULLUP |
digitalWrite(pin, v) / digitalRead(pin) | Digital output / input |
analogRead(pin) | 0 to 1023 |
analogWrite(pin, v) | PWM 0 to 255 on ~ pins |
delay(ms) / delayMicroseconds(us) | Blocking wait |
millis() | Time since start in ms |
pulseIn(pin, level, timeout) | Measure pulse width in µs |
map(x, a, b, c, d) | Rescale a number |
constrain(x, a, b) | Limit a number |
tone(pin, f) / noTone(pin) | Buzzer tone |
Serial.begin / print / println / available / read | Serial communication |
attach / write / read (Servo) | Servo control |
SoftwareSerial(rx, tx) | Extra serial port |
random(a, b) | Random number in a to b−1 |
A.3 Arduino UNO R3 Pin Summary
| Pin(s) | Notes |
|---|---|
| D0 (RX), D1 (TX) | Serial/USB |
| D2, D3 | External interrupts (D3 also PWM) |
| D3, D5, D6, D9, D10, D11 | PWM |
| D10 to D13 | SPI |
| D13 | On-board LED |
| A0 to A5 | Analog inputs (also digital 14 to 19); A4 SDA, A5 SCL |
| 5V, 3.3V, GND, Vin | Power |
A.4 Pin Maps Used in This Book
| Practical | Pins |
|---|---|
| 1 Blink | LED on D8 |
| 2 Knight Rider | LEDs on D2 to D6 |
| 3 Servo | Servo on D9, potentiometer on A0 |
| 4 and 5 Ultrasonic | Trig D9, Echo D10, LED D8 |
| 6 L298N | ENA D5, IN1 D7, IN2 D8, ENB D6, IN3 D9, IN4 D10 |
| 7 Bluetooth + motors | HC-05 TXD to D2, RXD from D3, motors as Practical 6 |