Arduino & Embedded C interview questions

25 questions from the Arduino & Embedded C course, each with the correct answer and an explanation. Try to answer before you open the answer.

Embedded Foundations

1. Which feature is typical of a microcontroller such as the ATmega328P?

  1. It requires an external hard drive to boot
  2. Gigabytes of RAM and a Linux operating system
  3. CPU, flash, RAM and peripherals on a single chip, running one program without an OS
  4. It cannot read input pins directly
Show answer

Answer: CPU, flash, RAM and peripherals on a single chip, running one program without an OS

MCUs integrate everything needed for a dedicated control task on one chip.

Lesson: Embedded Systems and Microcontrollers

2. What is an Arduino "core"?

  1. A package with the toolchain, Arduino API implementation and upload tools for a board family
  2. The CPU chip soldered on the board
  3. A cloud service that runs your sketch
  4. A type of breadboard
Show answer

Answer: A package with the toolchain, Arduino API implementation and upload tools for a board family

Installing the right core lets the same Arduino API compile for different chips.

Lesson: The Arduino Ecosystem

3. What happens after setup() finishes?

  1. The board waits for a command from the PC
  2. The program ends and the board turns off
  3. setup() is called again
  4. loop() is called repeatedly for as long as the board is powered
Show answer

Answer: loop() is called repeatedly for as long as the board is powered

There is no OS to return to, so the main loop never exits.

Lesson: Sketch Structure and the Build/Upload Flow

Digital Input and Output

4. With INPUT_PULLUP and a button wired to GND, what does digitalRead return while the button is pressed?

  1. HIGH
  2. LOW
  3. A random value
  4. The analog voltage
Show answer

Answer: LOW

The button connects the pin to ground, overriding the weak internal pull-up.

Lesson: LEDs, Buttons and Pull-ups

5. What does a software debounce do?

  1. Increases the voltage on the pin
  2. Accepts a new button state only after it has been stable for a short time
  3. Disables the internal pull-up
  4. Makes the button respond faster to every edge
Show answer

Answer: Accepts a new button state only after it has been stable for a short time

Stability over a time window filters out contact bounce.

Lesson: Debouncing Buttons

6. Why is millis()-based timing preferred over delay() in larger sketches?

  1. It disables interrupts for accuracy
  2. It makes the clock run faster
  3. It uses less flash memory than any delay
  4. It lets loop() keep running other tasks instead of busy-waiting
Show answer

Answer: It lets loop() keep running other tasks instead of busy-waiting

Cooperative, non-blocking checks keep the program responsive.

Lesson: Non-blocking Timing with millis()

Analog Input and PWM

7. What range does analogRead return on an Arduino Uno R3 by default?

  1. 0 to 1023
  2. 0 to 255
  3. 0 to 4095
  4. -512 to 511
Show answer

Answer: 0 to 1023

The ATmega328P ADC has 10-bit resolution.

Lesson: analogRead and the ADC

8. What does analogWrite(pin, 64) roughly produce on an Uno R3 PWM pin?

  1. A 64 Hz sine wave
  2. A steady 1.25 V DC voltage
  3. A square wave HIGH about 25 % of the time
  4. Nothing, because analogWrite is for inputs
Show answer

Answer: A square wave HIGH about 25 % of the time

64/255 is about a quarter duty cycle.

Lesson: PWM with analogWrite

9. A divider has R1 = 10 kΩ (top) and R2 = 10 kΩ (bottom) on a 5 V input. What is Vout?

  1. 1.25 V
  2. 5 V
  3. 2.5 V
  4. 10 V
Show answer

Answer: 2.5 V

Vout = 5 × 10k / (10k + 10k).

Lesson: Reading Sensors and Voltage Dividers

Communication Protocols

10. What must both ends of a UART link agree on?

  1. The baud rate and frame format
  2. The I2C address
  3. A shared clock line
  4. The SPI mode
Show answer

Answer: The baud rate and frame format

UART is asynchronous: timing comes from the agreed baud rate.

Lesson: Serial (UART) for Debugging and Data

11. How does an I2C controller select which device to talk to?

  1. Each device needs its own pair of wires
  2. By pulling that device's chip-select pin low
  3. By choosing a different baud rate
  4. By sending the device's address on the shared bus
Show answer

Answer: By sending the device's address on the shared bus

Addressing lets many devices share SDA and SCL.

Lesson: I2C with the Wire Library

12. Which bus is usually best for a fast display or SD card?

  1. I2C at 100 kHz
  2. SPI
  3. A software UART at 9600 baud
  4. analogWrite
Show answer

Answer: SPI

SPI is full-duplex and typically supports much higher clock speeds.

Lesson: SPI and Using Libraries Responsibly

Actuators and Power

13. Why is a flyback diode placed across a DC motor or relay coil?

  1. To make the motor spin faster
  2. To safely absorb the voltage spike produced when the inductive load is switched off
  3. To convert PWM into true analog voltage
  4. To raise the logic level from 3.3 V to 5 V
Show answer

Answer: To safely absorb the voltage spike produced when the inductive load is switched off

Inductors resist sudden current changes and generate a reverse spike that can destroy the transistor.

Lesson: Driving Motors and Relays Safely

14. What sets the angle of a typical hobby servo?

  1. The ADC reference
  2. The supply voltage level
  3. The number of I2C bytes sent
  4. The width of a repeating control pulse
Show answer

Answer: The width of a repeating control pulse

Roughly 1-2 ms pulses about every 20 ms map to the servo's range.

Lesson: Servos and Stepper Motors

15. You power servos from a separate 6 V supply. What else must you do?

  1. Connect the servo supply ground to the Arduino ground
  2. Connect the 6 V supply to an Arduino GPIO pin
  3. Nothing, the signals are isolated automatically
  4. Remove the Arduino ground connection
Show answer

Answer: Connect the servo supply ground to the Arduino ground

Signals are measured relative to ground, so both circuits need a common reference.

Lesson: Power Supplies, Current Budgets and Common Ground

Embedded C Under the Hood

16. How many bits is an int on an ATmega328P-based Arduino Uno R3?

  1. 32
  2. 8
  3. 16
  4. 64
Show answer

Answer: 16

AVR-GCC uses a 16-bit int, unlike most 32-bit platforms.

Lesson: Data Types and Fixed-width Integers

17. What does Serial.println(F("Hello")) achieve on an AVR board?

  1. Stores the text in EEPROM permanently
  2. Prints the text faster over USB
  3. Keeps the string literal in flash instead of copying it into SRAM
  4. Formats the text as floating point
Show answer

Answer: Keeps the string literal in flash instead of copying it into SRAM

F() saves scarce SRAM on AVR boards.

Lesson: Flash, SRAM, EEPROM, PROGMEM and F()

18. On the ATmega328P, which register sets whether a pin is an input or an output?

  1. DDRx
  2. PORTx
  3. PINx
  4. ADCSRA
Show answer

Answer: DDRx

DDR stands for Data Direction Register.

Lesson: Bit Manipulation, Registers and volatile

Interrupts, Timers and Low Power

19. Why should a variable shared between an ISR and loop() be declared volatile?

  1. So it becomes atomic automatically
  2. So it is stored in EEPROM
  3. So the ISR runs faster
  4. So the compiler re-reads it from memory instead of using a cached copy
Show answer

Answer: So the compiler re-reads it from memory instead of using a cached copy

volatile prevents caching; atomic access still needs interrupts disabled for multi-byte values on AVR.

Lesson: External and Pin-change Interrupts

20. On an Arduino Uno R3, which timer does millis() rely on?

  1. Timer1
  2. Timer0
  3. Timer2
  4. The watchdog timer
Show answer

Answer: Timer0

Changing Timer0 settings would break millis(), micros() and delay().

Lesson: Hardware Timers Overview

21. What happens when an ESP32 wakes from deep sleep?

  1. It continues from the line after esp_deep_sleep_start()
  2. It restarts and runs setup() again, keeping only data stored in RTC memory or flash
  3. All variables keep their values automatically
  4. It waits for a USB connection
Show answer

Answer: It restarts and runs setup() again, keeping only data stored in RTC memory or flash

Deep-sleep wake-up behaves like a reset.

Lesson: Low-power and Sleep Modes

Building Real Projects

22. What is the main benefit of a state machine in embedded code?

  1. It replaces all interrupts
  2. It removes the need for any timing
  3. It makes the code run in parallel on several cores
  4. Behaviour is organised into explicit states and transitions that are easy to reason about
Show answer

Answer: Behaviour is organised into explicit states and transitions that are easy to reason about

Explicit states replace tangled flags and nested conditions.

Lesson: State Machines for Embedded Logic

23. Where should Wi-Fi credentials for a public project live?

  1. In a separate file excluded from version control, with a committed template
  2. Directly in the main sketch so others can test it
  3. In a comment at the top of the README
  4. In the device name broadcast over Wi-Fi
Show answer

Answer: In a separate file excluded from version control, with a committed template

Credentials pushed to a public repository must be considered leaked.

Lesson: IoT with the ESP32

24. Which tool is best for seeing why an I2C transaction fails?

  1. A thermometer on the chip
  2. Adding a longer delay() at random places
  3. A logic analyser that captures and decodes SDA and SCL
  4. Recompiling with a different baud rate
Show answer

Answer: A logic analyser that captures and decodes SDA and SCL

Seeing the actual bus traffic shows missing ACKs, wrong addresses or timing issues.

Lesson: Debugging and Testing Embedded Code

25. Which item belongs on an embedded project checklist?

  1. Long Serial prints inside every ISR
  2. LEDs connected directly to pins without resistors
  3. Motors are driven through a driver with flyback protection and a separate supply sharing ground
  4. Wi-Fi passwords committed so teammates can build easily
Show answer

Answer: Motors are driven through a driver with flyback protection and a separate supply sharing ground

Safe power design protects both the board and the user.

Lesson: An Embedded Project Checklist

← Back to the course