Cambridge IGCSE Computer Science Notes

Chapter 3 · Hardware

3.2 Input and output devices

This large topic explains how common input and output devices work, why particular devices are chosen for particular applications, and how sensors, ADCs, DACs, microprocessors and actuators are combined in monitoring and control systems.

Input devicesOutput devicesSensorsADC & DACMonitoring & control

What you need to understand

You should be able to describe how the named input and output devices work and where they are used, compare suitable devices for a task, explain sensor systems and analogue/digital conversion, and trace monitoring and control processes using stored values, feedback and actuators.

3.2.1

Input devices

Input devices allow data to enter a computer system. In this topic the textbook covers barcode and QR-code scanners, digital cameras, keyboards, microphones, optical mice, 2D and 3D scanners and three touch-screen technologies.

Barcode scanners (readers)

A barcode represents digits using dark and light bars of different widths. The textbook example uses different patterns on the left and right sides of the code, separated by guard bars. Each digit contains two dark and two light lines; left-side digits begin with a light element and use an odd number of dark elements, while right-side digits begin with a dark element and use an even number. This helps the code to be read in either direction.

Course-book Figure 3.15 showing barcode digit patterns on the left-hand and right-hand sides
Course-book Figure 3.15: barcode digit patterns.

How a barcode is read

  1. A red laser or LED scans the barcode.
  2. Light areas reflect more light; dark bars reflect little or none.
  3. Photoelectric cells detect the reflected pattern.
  4. The changing light pattern is converted into digital data so the computer can identify the digits.

At a supermarket checkout

The barcode number is used as a key field to look up the stock record. The price and item details are returned to the point-of-sale terminal, stock quantity is reduced, the new stock value is written back to the database and compared with the re-order level. If the level is reached, more stock can be ordered automatically and a flag prevents repeated re-ordering until new stock arrives.

Management benefits

Faster price changes, up-to-date sales information, automatic stock control, no need to price every item individually, and easier analysis of buying habits when linked to loyalty cards.

Customer benefits

Faster queues, fewer pricing errors, an itemised bill, possible cost savings and improved tracking of sell-by dates.

Barcodes are also used in libraries to link a borrower to a book and to track its return date.

Quick response (QR) codes

A QR code is a two-dimensional matrix of light and dark squares. The book notes that it can hold far more information than a conventional barcode, including web addresses. Three large corner squares provide alignment; another smaller corner square helps the reader determine the correct size and camera angle.

Course-book Figure 3.17 showing a sample QR code
Course-book Figure 3.17: sample QR code.

How a QR code is used

  1. A phone or tablet camera captures the code.
  2. The QR app converts the square pattern into readable data.
  3. Browser or phone software interprets the decoded information.
  4. The user may be taken to a website, telephone number or electronic boarding pass.
Advantages over a traditional barcodeDisadvantages / risks
Stores much more information.More than one QR format exists.
Higher capacity permits stronger error checking and redundancy.Malicious code can be embedded; scanning may lead to fake sites, malware or unauthorised access.
Can be read by ordinary phone/tablet cameras rather than specialised laser readers.Users may scan codes without knowing where they lead.
Easy to transmit as an image or message and can be encrypted.

The source also introduces frame QR codes, which provide a canvas area for graphics or advertising logos within the code.

Digital cameras

Digital cameras use an embedded system to control functions such as shutter speed, autofocus, flash, aperture, image size and red-eye correction. When a picture is taken, light passes through the lens onto a light-sensitive array made from millions of tiny sensors/photodiodes (CCDs).

  1. Light is converted into tiny electrical charges by the sensor array.
  2. An analogue-to-digital converter (ADC) converts those charges into digital brightness values.
  3. Colour is also measured. The source describes a 24-bit RGB system with 8 bits for red, 8 for green and 8 for blue.
  4. The number of pixels influences file size and image detail; quality also depends on lens quality, sensor quality, lighting and the storage format.
Course-book Figure 3.22 diagram of how a digital camera works
Course-book Figure 3.22: digital camera image capture and conversion.

Keyboards

Keyboards remain a common way to enter text. Each pressed character corresponds to a code such as its ASCII value. They are relatively slow and can introduce typing errors; frequent use can also contribute to repetitive strain injury (RSI), which ergonomic keyboards are designed to reduce.

Under the keys is a membrane or circuit board. Pressing a key completes an electrical circuit. The CPU identifies which circuit was completed, refers to an index mapping and interprets the corresponding character.

Course-book Figure 3.25 showing how a key press completes a circuit and is interpreted
Course-book Figure 3.25: how a keyboard key press is recognised.

Microphones

A microphone converts sound waves into an analogue electrical signal. Sound vibrates a diaphragm; the attached cone and coil move backwards and forwards through a permanent magnetic field, inducing an electric current. A sound card or ADC can then convert that analogue current into digital values that a computer can store or process.

Course-book Figure 3.26 showing a diaphragm, coil and magnet in a microphone
Course-book Figure 3.26: how a microphone converts sound into an electric current.

Optical mouse

An optical mouse is a pointing device. The source describes a red LED illuminating the surface and a CMOS sensor capturing reflected patterns. A digital signal processor analyses changes between images and calculates movement coordinates so the on-screen pointer can move.

Course-book Figure 3.28 showing the LED, lenses, CMOS sensor and reflected light in an optical mouse
Course-book Figure 3.28: optical mouse.

Compared with an older mechanical mouse, there are no moving parts, dirt is less likely to interfere with operation and no special mouse surface is required. A wired mouse avoids wireless signal loss, avoids batteries and can be cheaper to operate.

2D scanners

A 2D scanner converts a paper document or photograph into an electronic image. The document is placed on a glass panel, illuminated by a bright lamp or LED, and a scan head moves across it. Mirrors direct the image to a lens; a CCD converts the received light into electrical charges, and software builds the digital image.

Course-book Figure 3.29 showing the stages in scanning a paper document
Course-book Figure 3.29: how a 2D scanner works.

OCR (optical character recognition) software can recognise scanned text and turn it into an editable text file. A scanned photograph can instead be stored as an image such as JPEG.

3D scanners and tomography

A 3D scanner records a solid object using measurements along x, y and z coordinates and produces a three-dimensional digital representation. The result can be used in CAD or sent to a 3D printer.

At airports, 2D scanning and OCR can read passport data. A scanned passport photograph can be compared with a newly captured facial image using measurements such as the distance between the eyes, nose width, cheek-bone shape, jaw length and eyebrow shape.

Course-book Figure 3.30 showing reference points used for face recognition
Course-book Figure 3.30: reference points used for face recognition.

Computed tomography (CT) is an application of 3D scanning. A solid object is represented by a series of thin 2D slices, which are stored digitally and combined to represent the whole 3D object. The book also names MRI and SPECT as related tomographic techniques using different energy sources.

Course-book Figure 3.31 showing tomography using slices through a solid object
Course-book Figure 3.31: tomography.

Touch screens

The source compares three technologies: capacitive, infrared and resistive.

Capacitive

A capacitive screen contains glass and a transparent conductive layer. Touching it changes the electrostatic field; a microcontroller calculates the point of contact. Surface capacitive systems use corner sensors and are generally limited to a bare finger or special stylus. Projective capacitive systems use an X–Y conductive matrix, can support multi-touch and can work with a wider range of touch inputs.

Course-book Figure 3.32 showing the layers in a capacitive touch screen
Course-book Figure 3.32: capacitive touch screen.

Advantages: good image clarity, durability, scratch resistance and multi-touch for projective systems. Drawbacks: surface capacitive systems require a suitable touch input and capacitive screens can be affected by electromagnetic radiation.

Infrared

Infrared transmitters and sensors form a grid around the screen. A touch blocks some beams, reducing the infrared signal at particular sensors; the microcontroller uses this to locate the touch.

Course-book Figures 3.33 and 3.34 showing infrared touch-screen transmitters, sensors and a broken beam
Course-book Figures 3.33–3.34: infrared touch screen.

Advantages: multi-touch, durable and still usable if the screen is scratched or cracked. Drawbacks: sensitivity to water/moisture, accidental activation if beams are disturbed and possible light interference.

Resistive

Two resistive layers are separated by air or inert gas. Pressing the flexible upper layer makes the two coated surfaces touch, completing a circuit. The changed voltage identifies the touch position.

Course-book Figure 3.35 showing the layers in a resistive touch screen
Course-book Figure 3.35: resistive touch screen.

Advantages: good resistance to dust/water and works with fingers, stylus or gloves. Drawbacks: lower sensitivity, no multi-touch, poorer sunlight visibility and greater vulnerability to scratches.

Check the input-device section.
3.2.2

Output devices

Output devices present or act on the results of computer processing. The textbook covers actuators, projectors, printers, screens and loudspeakers.

Actuators

An actuator is a mechanical or electromechanical device that turns a computer-controlled signal into a physical action. Examples include relays, motors and solenoids. In a solenoid, current through a coil creates a magnetic field that can move a plunger in a straight line or, in some designs, rotate it.

Course-book Figure 3.36 showing a solenoid coil and magnetic field
Course-book Figure 3.36: a solenoid.

Light projectors

Digital light projector (DLP)

A DLP projector uses a digital micromirror device (DMD) containing a huge number of tiny mirrors. A mirror tilted toward the light source represents an ON state and one tilted away represents OFF. Repeated switching creates brightness levels; a colour filter provides red, green and blue components so a full-colour image can be projected.

Course-book Figure 3.37 showing the optical path through a DLP projector
Course-book Figure 3.37: digital light projector.

Liquid crystal display (LCD) projector

A powerful white light is separated into red, green and blue components by dichroic mirrors. Each colour passes through its own LCD panel to form a monochrome version of the image. A prism recombines the three coloured images, and the result is projected through the lens.

Course-book Figure 3.38 showing the light path through an LCD projector
Course-book Figure 3.38: LCD projector.
DLPLCD projector
Higher contrast, good reliability/longevity, quieter and often smaller/lighter.Sharper image and better colour saturation.
Can suffer moving-image shadows and colour definition may be weaker.Contrast may be lower; organic panels can degrade and have a limited life.
Well suited to dusty/smoky environments.More energy-efficient and therefore usually produces less heat.

Inkjet printers

An inkjet printer uses a print head containing nozzles, ink cartridges, a stepper motor/belt to move the head and a paper-feed system. The source describes two methods of creating ink droplets: thermal bubble, where heat creates expanding bubbles that eject ink, and piezoelectric, where a crystal vibrates to force ink from a nozzle.

  1. Document data is sent to a printer driver.
  2. The driver converts it to a form the printer understands and checks printer availability.
  3. Data is stored in a printer buffer.
  4. Paper is fed in; sensors detect missing or jammed paper.
  5. The print head moves across the page spraying the required mixture of ink.
  6. The paper advances slightly after each pass until the page is complete.
  7. Further buffered data is printed; when the buffer empties, the printer can interrupt the CPU to request more data.

Inkjet printers are appropriate for one-off photographs or small numbers of good-quality colour pages, where small cartridges and paper trays are not a problem.

Laser printers

Laser printers use powdered toner and static electricity and normally produce a whole page at once. A positively charged drum is scanned by a laser, which removes charge in areas corresponding to the page image. Positively charged toner sticks to the negatively charged image areas; the toner transfers to negatively charged paper and is permanently fused by heated rollers. A discharge lamp resets the drum.

Laser printers suit high-volume, fast, high-quality printing because they use larger toner cartridges and paper trays.

3D printers

3D printers build solid objects layer by layer using materials such as powdered resin, powdered metal, paper or ceramic. This is additive manufacturing, unlike subtractive methods that remove material from a larger block.

Course-book Figure 3.43 showing the stages from CAD design to a finished 3D-printed object
Course-book Figure 3.43: creating an object using a 3D printer.

Uses given in the source include customised prosthetic-limb coverings, precision reconstructive-surgery parts, lightweight aerospace components, fashion/art and replacement parts for products that are no longer manufactured.

LED, LCD and OLED screens

LED screens

A true LED screen is made from tiny red, green and blue light-emitting diodes. Varying current changes their brightness and produces different colours. The source notes that these are commonly used for large outdoor displays.

LCD screens with LED backlighting

LCD pixels do not generate their own light, so a backlight is required. Modern LCD displays commonly use blue-white LEDs behind the LCD panel. Compared with older CCFL backlights, LEDs reach full brightness quickly, produce a whiter/brighter light, allow thinner displays, last longer and use less power.

OLED

Organic light-emitting diodes use organic semiconductor layers between electrodes. When an electric field is applied, the layers emit light, so no separate backlight is needed. OLED layers can be very thin and flexible.

Course-book Figure 3.44 showing the layers in an OLED screen
Course-book Figure 3.44: OLED screen structure.

The source highlights thinner/lighter construction, flexibility, bright output, reduced power consumption due to no backlight and a wide viewing angle as advantages of OLED technology.

Loudspeakers

Digitally stored sound must be converted before it can drive an analogue loudspeaker. The digital data passes through a DAC, then an amplifier increases the current. In the speaker, current through a coil creates a changing magnetic field. Interaction with a permanent magnet moves the coil and attached cone, producing sound waves.

Course-book Figure 3.46 showing digital data passing through a DAC and amplifier to a speaker
Course-book Figure 3.46: digital-to-analogue conversion.
Course-book Figure 3.47 showing the coil, magnet and cone in a loudspeaker
Course-book Figure 3.47: how a loudspeaker works.
Check the output-device section.
3.2.3

Sensors

Sensors are input devices that measure physical properties in their surroundings. Real-world measurements are generally analogue, so an analogue-to-digital converter (ADC) may be required before a computer can process them. Where a computer must control an analogue device such as a motor or valve, a digital-to-analogue converter (DAC) may be required.

Course-book Figure 3.49 showing analogue data being converted to digital data by an ADC
Course-book Figure 3.49: analogue-to-digital conversion.

Sensors provide readings continuously. The computer or microprocessor samples and analyses the incoming data. In a control system, an output may change the environment and therefore alter the next sensor reading. This is feedback.

Common sensors and uses

SensorWhat it measures / detectsExamples from the source
TemperatureTemperature of surroundings.Central heating; chemical processes; greenhouse.
MoistureWater level in a material such as soil, often using resistance.Greenhouse soil; food-processing moisture.
HumidityWater vapour in air.Buildings; microchip factory; greenhouse.
LightBrightness using photoelectric cells.Street lights; automatic car headlights.
Active infraredWhether an infrared beam has been interrupted.Security systems; rain/windscreen applications.
Passive infraredHeat radiation emitted by an object.Body-heat security detection; freezer/chiller monitoring.
PressureApplied pressure, converted by a transducer.Weighing lorries; reactor gas pressure.
Acoustic / soundSound converted to electrical signals.Security footsteps; leaking pipe detection.
GasGas concentration such as oxygen or carbon dioxide.Airport pollution; greenhouse; car exhaust.
pHAcidity/alkalinity.Greenhouse soil; chemical processes.
Magnetic fieldChanges in magnetic fields.Mobile/CD applications; anti-lock braking.
AccelerometerAcceleration and motion/change in velocity.Airbags; phone screen orientation.
ProximityPresence of a nearby object.Switching off a phone screen when held near the face.
Flow rateRate of moving liquid or gas.Respiratory devices; gas pipes.
LevelLiquid/material level using ultrasonic, conductivity, capacitance or other methods.Fuel tank; pharmaceutical powder; leak detection.

Monitoring versus control

Both systems start with sensors sending data, conversion to digital if needed and comparison with stored values. The key difference is what happens next.

Course-book Figure 3.50 comparing monitoring and control systems using sensors
Course-book Figure 3.50: monitoring and control systems.

Monitoring

The computer watches the process. If a value is outside the acceptable range, it may display a warning or sound an alarm, but it does not directly change the process being observed.

Control

If a value is outside range, the computer sends signals to devices such as valves or motors. The output changes the process, which changes future sensor inputs — a feedback loop.

Monitoring applications

Security system

The source combines infrared, acoustic and pressure sensors. The sensor data is digitised if necessary and sampled by the computer. If a reading is outside the acceptable range, the computer can activate a siren or flashing light. A DAC may be used where the output device requires analogue control.

Course-book Figure 3.51 showing sensors feeding a computer and outputs to a siren and lights
Course-book Figure 3.51: security monitoring system.

Hospital patient monitoring

Temperature, heart rate, breathing rate and other vital signs can be measured continuously. The computer samples the sensor data, compares it with entered acceptable ranges, displays values and raises an alarm if a reading moves outside the permitted range.

Control applications

Street lighting

A light sensor sends readings through an ADC to a microprocessor. If the reading is below the stored threshold, the lamp is switched on; if it is at or above the threshold, it is switched off. The source includes a time delay between checks to prevent the lamp repeatedly switching because of brief changes such as cloud cover.

Course-book Figure 3.52 showing a light sensor system controlling a street light
Course-book Figure 3.52: street-light control.

Anti-lock braking system (ABS)

Magnetic-field sensors monitor wheel rotation. If one wheel begins to lock, the microprocessor compares it with the other wheels and reduces braking pressure to that wheel. The process is repeated many times per second; braking pressure can be adjusted repeatedly to keep wheel speeds similar.

Central heating

The required temperature is stored as a pre-set value. A temperature sensor sends readings through an ADC to the microprocessor. If the temperature falls below the pre-set value, the controller sends signals through DACs to actuators that open the gas valve and switch on the water pump.

Course-book Figure 3.53 showing sensor, ADC, microprocessor, DACs, gas heater and water pump
Course-book Figure 3.53: central-heating control.

Chemical process control

The source example requires a temperature above 70°C and pH below 3.5. Temperature and pH sensors feed data through an ADC. The computer compares each reading with its stored target and controls the heater and an acid valve through DAC-controlled outputs.

Greenhouse environment

The textbook example combines humidity, moisture, temperature, pH and light sensors. Each reading is compared with a stored value and the computer can open windows, spray water, switch on a heater, add water, add acid or alkali, close blinds or switch on artificial light. The process repeats continuously.

Course-book Figure 3.54 showing greenhouse sensors, ADC, computer, DAC and controlled devices
Course-book Figure 3.54: greenhouse environment control.
Exam pattern for sensor questions: sensor → ADC if needed → microprocessor samples data → compare with stored/pre-set value → decision → output signal → DAC if needed → actuator/device → changed condition produces new sensor readings.
Check sensors, monitoring and control.

Topic 3.2 revision checklist

Explain how barcode and QR-code systems work and where they are used.
Describe how digital cameras, keyboards, microphones, optical mice and scanners input data.
Compare capacitive, infrared and resistive touch-screen technologies.
Explain actuators and the operation of DLP/LCD projectors.
Describe inkjet and laser printing processes and select a suitable printer for an application.
Explain additive 3D printing and the production stages.
Distinguish true LED, LCD with LED backlight and OLED screens.
Explain DAC/amplifier/loudspeaker conversion.
Know the purpose and typical uses of the sensor types in the topic.
Explain ADC, DAC, monitoring, control and feedback.
Trace security, patient monitoring, street-light, ABS, heating, chemical-process and greenhouse systems.
Ready for a mixed Topic 3.2 check?
← Topic 3.1 Computer architectureComputer Science contentsTopic 3.3 Data storage →