← Unit 6: Computer Interfacing
TEJ3M · Unit 6 test review
Computer Interfacing: Test Review
Everything for the Unit 6 test on one page: the key facts from all 4 lessons, the mistakes that cost the most marks, and a practice test that points you back to the lessons you need.
Key facts
Microcontrollers and the Arduino
- A microcontroller has CPU, memory and I/O on one chip and runs with no operating system.
setup()runs once at power-up;loop()runs forever.- Pin configuration goes in
setup(); behaviour goes inloop(). - An Uno pin can supply at most 40 mA, and all pins together at most 200 mA.
- PWM is available only on pins 3, 5, 6, 9, 10 and 11.
- Analog inputs A0–A5 report 0–1023 for 0–5 V.
Serial.begin(9600)plusSerial.println()is how you debug a sketch.
Digital Input and Output
- An unconnected input floats and reads random values — every button needs a pull-up or pull-down resistor.
- Pull-down: resistor to ground, button to 5 V, resting LOW. Pull-up: resistor to 5 V, button to ground, resting HIGH.
INPUT_PULLUPuses the chip's internal resistor, so pressed reads LOW.- 10 kΩ is the standard pull resistor value: defines the level firmly, wastes only 0.5 mA.
- Switch bounce produces multiple transitions from one press — debounce in software or hardware.
delay()blocks everything;millis()lets you time without blocking.
Analog Inputs and Sensors
- The Uno's ADC is 10-bit: levels, reported as 0–1023 across 0–5 V.
- , and one step is about 4.9 mV.
- Use
5.0and1023.0in C, or integer division silently returns 0. - A resistive sensor needs a voltage divider, because an analog pin measures voltage, not resistance.
- Choose the fixed resistor near the middle of the sensor's resistance range for maximum sensitivity.
- A TMP36 gives 10 mV per °C with a 500 mV offset.
- Never apply more than 5 V to an analog input.
PWM, Motors and Control Systems
- PWM switches a digital pin rapidly; duty cycle sets the average voltage.
analogWrite(pin, value)takes 0–255. .- PWM is available only on pins 3, 5, 6, 9, 10 and 11 on an Uno.
- A motor needs a transistor (for current) and a flyback diode (for the inductive spike).
- An H-bridge reverses a motor; closing both switches on one side causes destructive shoot-through.
- A servo reads pulse WIDTH: 1.0 ms = 0°, 1.5 ms = 90°, 2.0 ms = 180°, repeated every 20 ms.
- Separate supplies must share a common ground.
- Closed loop measures the result and corrects; open loop does not.
Where marks get lost
- Putting
pinMode()inloop()instead ofsetup(). (Microcontrollers and the Arduino) - Putting the program's actual behaviour in
setup(), so it runs once and appears dead. (Microcontrollers and the Arduino) - Connecting a motor, relay or long LED strip directly to a pin. (Microcontrollers and the Arduino)
- Using pins 0 and 1 for a project, which conflicts with USB uploading. (Microcontrollers and the Arduino)
- Forgetting
Serial.begin()and then wondering why the Serial Monitor is blank. (Microcontrollers and the Arduino) - Setting the Serial Monitor to a different baud rate than the sketch, which produces garbage characters. (Microcontrollers and the Arduino)
- Powering a motor from the Arduino's 5 V pin, which browns out the board and resets it mid-program. (Microcontrollers and the Arduino)
- Wiring a button with no pull resistor, producing an input that reads randomly. (Digital Input and Output)
- Forgetting that
INPUT_PULLUPinverts the logic — pressed reads LOW, not HIGH. (Digital Input and Output) - Not debouncing, so one press registers as several. (Digital Input and Output)
- Using
delay()in a sketch that must stay responsive to inputs. (Digital Input and Output) - Connecting a button between 5 V and ground with no resistor at all — a dead short when pressed. (Digital Input and Output)
- Forgetting
pinMode()in setup, leaving the pin in its default input state sodigitalWriteseems to do nothing. (Digital Input and Output) - Using integer literals in the ADC conversion, so the result truncates to 0. (Analog Inputs and Sensors)
- Connecting a resistive sensor directly to an analog pin with no divider — the pin cannot measure resistance. (Analog Inputs and Sensors)
- Choosing a fixed resistor far from the sensor's range, giving a tiny usable output swing. (Analog Inputs and Sensors)
- Forgetting the TMP36's 500 mV offset, which puts every reading 50 °C too high. (Analog Inputs and Sensors)
- Applying more than 5 V to an analog pin. (Analog Inputs and Sensors)
- Comparing a noisy reading against a single threshold with no hysteresis, so the output flickers. (Analog Inputs and Sensors)
- Dividing by 1024 instead of 1023 — a small error, but the maximum reading maps to 5 V, not just below it. (Analog Inputs and Sensors)
- Calling analogWrite an analog output. It is a square wave whose duty cycle you control. (PWM, Motors and Control Systems)
- Using analogWrite on a pin without PWM — pins 3, 5, 6, 9, 10 and 11 only on an Uno. (PWM, Motors and Control Systems)
- Driving a motor straight from a pin, destroying it. (PWM, Motors and Control Systems)
- Omitting the flyback diode, so the inductive spike damages the transistor. (PWM, Motors and Control Systems)
- Forgetting to connect the grounds of two separate supplies. (PWM, Motors and Control Systems)
- Confusing a servo's pulse width with duty cycle. A servo reads the width of the pulse, not the fraction of the period. (PWM, Motors and Control Systems)
- Powering a servo from the Arduino's 5 V pin, causing brownout resets that look like software crashes. (PWM, Motors and Control Systems)
- Calling a timed motor run "closed loop" — without a sensor measuring the result, it is open loop. (PWM, Motors and Control Systems)
Practice test
24 questions from across the unit. Each one shows the lesson it comes from.
- Microcontrollers and the Arduino1Which function runs only once when an Arduino is powered on?
- Microcontrollers and the Arduino2What is the maximum current a single Arduino Uno pin should source, in milliamps?mA
- Microcontrollers and the Arduino3The Serial Monitor shows nothing while a sketch runs. What is the most likely cause?
- Microcontrollers and the Arduino4Why can't a 250 mA relay coil be driven directly from a digital pin?
- Microcontrollers and the Arduino5Match each Arduino feature to its description.Digital pins 0–13Pins 3, 5, 6, 9, 10, 11Pins A0–A5VIN
- Microcontrollers and the Arduino6A microcontroller has no operating system. What follows from that?
- Digital Input and Output7A button is wired between a pin and 5 V with no other components. What does the pin read when the button is NOT pressed?
- Digital Input and Output8What is the standard resistance value for a pull-up or pull-down resistor?
- Digital Input and Output9A counter increments several times from one button press. What is happening?
- Digital Input and Output10How much current flows through a 10 kΩ pull-down resistor when the pin is pulled to 5 V? Answer in milliamps.mA
- Digital Input and Output11Order the steps of a software debounce routine.
- 1Wait about 50 ms
- 2Act once, then wait for the button to be released
- 3Re-read the pin to confirm it is still LOW
- 4Detect the pin reading LOW
- Digital Input and Output12Match each function to what it does.
pinMode(p, OUTPUT)digitalWrite(p, HIGH)digitalRead(p)millis() - Analog Inputs and Sensors13
analogRead()returns 512. What voltage is on the pin? Answer in volts to 2 decimal places.V - Analog Inputs and Sensors14How many discrete levels can a 10-bit ADC distinguish?levels
- Analog Inputs and Sensors15In C,
analogRead(A0) * 5 / 1023gives 0 for most readings. Why? - Analog Inputs and Sensors16A TMP36 outputs 750 mV. What temperature is that, in °C?°C
- Analog Inputs and Sensors17A sensor outputs up to 9 V. What must you do before connecting it to an analog pin?
- Analog Inputs and Sensors18What is the smallest voltage change an Uno's 10-bit ADC can detect across a 5 V range? Answer in millivolts, to 1 decimal place.mV
- PWM, Motors and Control Systems19What duty cycle does
analogWrite(pin, 51)produce? Answer as a percentage.% - PWM, Motors and Control Systems20Why is a flyback diode fitted across a motor?
- PWM, Motors and Control Systems21Which system is closed loop?
- PWM, Motors and Control Systems22What
analogWrite()value gives a 40% duty cycle? Round to the nearest whole number. - PWM, Motors and Control Systems23Order the elements of a closed-loop control system.
- 1The controller compares the set point with the measurement
- 2A sensor measures the result and feeds it back
- 3The actuator changes the output
- 4A set point is specified
- PWM, Motors and Control Systems24Match each component to its role in a motor circuit.TransistorFlyback diodeH-bridgeCommon ground
Endless drill
Fresh numbers every time, for the calculation questions in this unit.
Endless drillnew numbers every time
Generating a problem…