Tech Centre — FAQs (Part A)

Sensors, Servos & Motors, Microcontrollers, Power & Batteries, Wiring & Connectors.

Sensors

Ultrasonic ranging, IR reflectance, and general sensor setup & smoothing.

How do I wire an HC-SR04 ultrasonic sensor?

Connect VCC to 5 V, GND to GND, TRIG to a digital output, and ECHO to a 5 V–tolerant input. On 3.3 V boards, level-shift ECHO with a resistor divider. Keep TRIG/ECHO leads short (under ~30 cm) and add a ~30 ms timeout so your program never blocks if no echo is received. Mount square to the target; soft, angled or glossy surfaces can scatter sound. Trigger for ≥ 10 µs; distance in cm ≈ microseconds / 58. Take several readings and reject impossible values.

My ultrasonic readings jump — how do I smooth them?

Take 3–7 samples per update and use a median or trimmed mean; leave 60–100 ms between bursts; ensure other modules aren’t pinging simultaneously. Clamp to realistic range and apply a light EMA (α≈0.2–0.4). Aim perpendicular, avoid absorbent materials, and add a short tube shroud if reflections cause jitter.

What cable length is safe for HC-SR04?

Keep TRIG and ECHO under ~30 cm on jumper wire. For longer runs, use twisted pair or shielded cable; add 100–220 Ω series on TRIG and level-shift/buffer ECHO at the MCU end. Place 0.1 µF decoupling near VCC/GND. Consider bus-based distance sensors for very long wiring.

Triple IR line sensor: mounting height and setup

Start 3–5 mm above the surface; if trimmers are present, set at operating height for clean transitions. Shield from ambient light, avoid glossy floors, and read raw analogs during calibration to set robust thresholds with margin.

How do I implement basic 3-sensor line following?

Begin with majority logic: centre=straight; left/right steer toward the line; if none, slow and search. Then move to proportional control: error ∈ {−1,0,+1} and correction = Kp×error (with clamp). Add small derivative to reduce overshoot and cap top speed while tuning.

How do I calibrate an IR reflectance array?

Sweep over line and background at startup; record per-channel min/max; set mid-threshold with hysteresis. Re-run when lighting or surfaces change; keep analog grounds quiet and route motor returns away from sensors.

Filtering noisy analog sensors

Add 0.1 µF decoupling at the sensor, keep analog leads short, sample multiple times and average or use EMA. Maintain steady sampling cadence; separate analog grounds from high-current returns and compensate if the sensor is ratiometric to supply.

Can I blend an IMU with line sensors?

Yes. Fuse IMU heading with line error to hold straighter course on shiny/broken lines. Use IMU heading to limit overcorrection when line signal is ambiguous; if the line is lost, hold last heading, slow, and search until reacquired.

Servos & Motors

Power rails, jitter fixes, and startup behavior for hobby servos and DC gear motors.

Safest way to power multiple servos

Use a dedicated 5–6 V rail sized for worst-case combined stall current. Do not power servos from the MCU regulator. Share a common ground at a star point; add bulk caps (~1000 µF per 3–4 micro servos) plus 0.1 µF decouplers.

Reducing servo jitter

Keep rails stiff with short, thicker leads and local caps. Generate a clean 50 Hz frame, route PWM away from motor wiring, check for mechanical binding, reduce commanded travel near endpoints, and consider a small signal deadband.

Do TT gear motors require drivers?

Yes. Use an H-bridge sized for stall current and back-EMF. Provide flyback protection if not onboard; twist motor leads; keep driver close to motors with short, stout power wiring.

Softening servo startup

On reset, command a safe neutral before enabling torque and ramp pulse width over 300–600 ms. This reduces spikes and avoids slamming hard stops; increase ramp time for geared or loaded mechanisms.

Wheel encoder basics for a line-follower chassis

Use interrupters or magnetic encoders on interrupt-capable pins; debounce/filter edges; compute speed from ticks/time and distance from integrated ticks; linearize speed vs PWM and equalize left/right drive.

Microcontrollers

Arduino, ESP32, RP2040 wiring and timing best practices.

Using HC-SR04 on 3.3 V boards (ESP32 or RP2040)

Power HC-SR04 from 5 V. TRIG accepts 3.3 V; ECHO outputs ~5 V and must be level-shifted. Measure pulse width with timeout; on ESP32/RP2040 prefer hardware capture peripherals over busy-waiting to keep the loop responsive.

Which pins should I use for TRIG and ECHO on Arduino Uno?

TRIG can be any digital output. For ECHO timing use external interrupt pins (D2/D3) to capture edges without busy-waiting; or measure pulse width with a timeout and keep other ISRs brief.

Are all pins 5 V-tolerant?

5 V boards expect 5 V logic but that is not “tolerance” in the protection sense. On 3.3 V MCUs like ESP32/RP2040 most GPIOs are not 5 V-tolerant; level-shift any 5 V outputs (e.g., HC-SR04 ECHO).

Will the Servo library clash with PWM on certain pins?

On AVR, Servo and PWM share timers on some pins; this can change PWM frequency or behavior. Prefer pins driven by different timers and consult the board's pin-to-timer map.

How do I recover if the bootloader seems broken?

Reflash via ISP with correct fuses/clock. Many boards support double-tap reset to re-enter bootloader. After recovery, load a minimal known-good sketch before returning to the main project.

What is a good serial debug strategy?

Print short, consistent lines at fixed cadence including time and key variables; use a serial plotter. Avoid printing in critical loops; enable verbose logs on demand only.

Power & Batteries

Regulator sizing, brown-out avoidance, and battery planning.

How do I size a battery for my motors and servos?

Sum typical current, add 30–50% headroom, and ensure wiring/regulators tolerate brief stall peaks. Validate under worst-case maneuvers while monitoring rail voltage; fix dips by wiring/regulator upgrades or reduced acceleration.

Can I power everything from a single Li-ion cell?

Yes, with proper regulation. Boost to 5 V for logic and provide a separate 5–6 V rail for servos via high-current buck/UBEC. Include a fuse and low-voltage cutoff; validate under worst-case motion.

How do I avoid brown-outs when servos move?

Add bulk capacitance near the servo rail (~1000 µF per 3–4 micro servos), keep leads short/thick, and ramp motion. Ensure rail stays above ~4.8 V; fix resets by improving grounding/regulators or mechanics.

What are good grounding practices for small robots?

Use star ground, twist power/ground pairs, keep motor/servo returns away from sensor grounds. If analogs are unstable, revisit ground routing before software filters.

Do I need reverse-polarity protection?

Strongly recommended. A series Schottky is simple but wastes voltage; ideal-diode or P-MOSFET is higher efficiency. Mark polarity clearly and re-test under load after adding protection.

How do I size a regulator for servo and motor loads?

Choose ≥1.5× expected continuous current and good transient response. Prefer switching regulators; add bulk caps close to loads; upgrade rating or split rails if hot or drooping.

Wiring & Connectors

I²C pull-ups, serial basics, breadboard power, screw terminals, and avoiding reversed connectors.

How should I handle I²C pull-ups with sensors?

I²C needs pull-ups to bus voltage. Many breakouts include them; too many in parallel lowers resistance and distorts edges. Aim ~4.7 kΩ per line for short runs at 100–400 kHz; remove redundant pull-ups and shorten wires if issues arise.

Why does my serial output appear garbled?

Usually a baud mismatch or power-only USB cable. Match Serial.begin to terminal rate; use a known data-capable cable; avoid heavy printing in time-critical loops; add a debug flag for verbose logs.

Best practice for breadboard power rails

Use consistent colors and bridge split rails. Keep servos off the breadboard; use screw terminals or power boards. Provide strain relief; keep runs short; label rails/connectors for quick checks.

How tight should screw terminals be?

Tighten until a firm tug doesn’t pull the wire. Tin or use ferrules with stranded wire; re-check after first heating cycle; prefer rising-clamp terminals where possible.

How do I avoid reversed connectors?

Use keyed housings and clear polarity marks; standardize servo-style 3-wire order; add arrows/labels at power entry; peer-check orientation during class.

What wire gauge should I use for servos and motors?

22–24 AWG for short micro-servo leads; 20–22 AWG for battery-to-regulator and motor drivers depending on current/run length. Keep runs short and twist power/ground; upgrade gauge if resets occur.

Back to top

Tech Centre — FAQs (Part B)

Calibration & Tuning, Troubleshooting, Classroom Use, General & Support, Safety.

Calibration & Tuning

PID basics, drift fixes, speed consistency, and mounting tips.

Do I need PID for a line follower?

Start with P-only and raise Kp to gentle oscillation, then back off. Add small D to tame overshoot; I is rarely needed and can wind up.

Line sensor threshold keeps drifting — what should I do?

Re-calibrate at startup over line and background; set mid-threshold with hysteresis; allow quick re-run when lighting changes; verify sensor height/angle.

Robot oscillates on straights — what should I change?

Lower Kp or add small D; reduce top speed while tuning; check mechanics (wheel diameters, free bearings, square sensor bar) and threshold placement.

How do I keep speed consistent as the battery discharges?

Use closed-loop velocity with encoders; or scale open-loop PWM based on measured battery voltage. Regulate the motor rail if possible; cap max speed as voltage falls.

What wheels or tyres work best for line following?

Soft rubber with consistent left/right diameter. If chatter occurs, use slightly harder compound or lower speed. Keep tyres clean for predictable friction.

Tips for mounting sensors mechanically

Use slotted mounts for height/angle adjustment; add light shields for IR; use thread-lock on metal threads; provide strain relief and label tuned positions.

Does chassis alignment really matter?

Yes. Small skew biases the robot. Square axles, match wheel spacing, and keep the sensor bar perpendicular; test drift on a straight line and fix mechanics before raising gains.

Troubleshooting

Bring-up, lost line, veering, resets, and code size.

Quick sensor bring-up checklist

Load a minimal sketch to print raw readings; verify supply voltage and common ground; add timeouts and basic filtering after raw behavior is healthy; keep a known-good reference to compare when regressions appear.

Ultrasonic reports zero at long range — what’s going on?

Increase timeout, aim perpendicular, avoid soft/angled materials, trigger modules one at a time to prevent crosstalk; consider a different sensing method for difficult environments.

Robot veers to one side — how do I correct it?

Match wheel diameters and tyre wear; verify motor polarity; balance PWM via encoder counts; remove mechanical drag; apply small software trims after hardware symmetry.

Servos twitch when uploading code — why?

Pins float during reset; disconnect servo power while flashing or command neutral early in setup. Keep signal lines short; add small pull-down if needed; reduce mechanical load while updating.

My sketch is too large for the board — what can I do?

Remove unused libraries/assets; avoid unnecessary floating point; use compile-time flags; store strings in flash; prefer smaller integer types; split examples into focused sketches.

How long should a starter build take?

Budget 60–90 minutes for assembly/wiring with checkpoints; follow with calibration/first-run code. Keep a prepared demo robot as reference for wiring/power sanity checks.

Classroom Use

Assessment, logistics, accessibility, and resource reuse.

What are good assessment ideas for STEM robotics?

Score wiring accuracy, code readability, and track performance; include short oral explanations. Offer extension challenges (chicanes, variable lines) to stretch advanced groups.

How can I manage 20+ students with limited kits?

Use rotating roles (builder/scribe/tester); color-code kits; centralize tools; keep a spare bin and a known-good reference build; encourage brief daily reflections.

Any accessibility considerations for activities and materials?

Provide large-print diagrams and color-blind-safe palettes; add tactile markers and alternate input methods; allow alternative assessments; solicit feedback and iterate.

Where can I get wiring diagrams and printable resources?

Provide PNG/SVG/PDF diagrams with clear pin labels and voltage callouts; include color and high-contrast mono versions; A4 sizing with 10–12 pt labels; include legend and version/date box.

How should example code be structured for students?

Keep sketches approachable: constants/config at top; init IO/serial in setup; non-blocking loop with helpers (readSensors, decide, drive). Include scaffolded “Try This” exercises; keep naming/baud consistent.

Can I reuse code and diagrams in my class or club?

Yes. Resources are intended for remixing and sharing; keep attribution headers intact; contribute improvements back with a brief changelog.

General & Support

Docs, downloads, debug strategy, and contacting support effectively.

Where do I find board documentation and downloads?

Use official board docs for pin maps, voltage limits, and supported libraries; keep PDFs/screenshots for offline reference; print the chosen pinout for bench checks.

How can I search the Technical Centre efficiently?

Use focused phrases (e.g., ultrasonic timeout, micro servo jitter, line sensor threshold); maintain a list of key articles; use a lab notebook to log thresholds, gains, and observations.

How do I contact support effectively?

Include a clear summary, wiring photo, short video if possible, and a minimal reproduction sketch. Provide board model, power source, and recent changes for faster diagnosis.

Safety

Battery handling, ESD/electrical, and mechanical safety for labs and classrooms.

What are the basics of battery handling for classrooms and hobbyists?

Never short cells; check polarity before power-up; supervise Li-ion charging in ventilated areas; avoid leaving cells connected when idle; insulate terminals and teach safe storage/transport; include low-voltage cutoff where appropriate.

How do I practice ESD and electronics safety?

Power down before rewiring; avoid metal benches when live; use ESD mats/straps for sensitive ICs; keep drinks away; double-check polarity/voltage; ask for peer checks on power wiring if unsure.

What mechanical safety should students keep in mind?

Watch pinch points near gears/servos; secure clothing/hair; organize tools; wear eye protection when cutting/drilling; remove power before adjustments to prevent unexpected motion.

Back to top