StudyVault
Home Unit Overview Exam Technique Revision Techniques ← Previous Lesson Next Lesson →

← Back to Dashboard

Overlay:
0:00 / 0:00 Narration generated using AI text-to-speech.

Microcontrollers and Flowchart Programming

What Is a Microcontroller?

A microcontroller is a complete computer on a single chip. Unlike a general-purpose processor, it is designed to control a specific electronic system — reading sensor inputs, making decisions, and driving output devices, all according to a program stored in its internal memory. The PIC (Peripheral Interface Controller) family of microcontrollers is widely used in GCSE Electronics practical work, though the principles apply across any programmable device.

Microcontrollers sit in the processing stage of an electronic system. They replace whole collections of discrete logic gates, timers and counters with a single chip that can be reprogrammed whenever the specification changes. This flexibility is one of the main reasons microcontrollers have displaced dedicated circuits in most consumer and industrial products.

Key Fact

A microcontroller is a programmable integrated circuit containing a processor, memory and input/output ports on a single chip. It replaces multiple discrete components and can be reprogrammed to change the system’s behaviour without rewiring.

Inputs and Outputs of a Microcontroller System

A microcontroller’s pins are configured as either inputs or outputs under program control:

  • Input pins read digital signals from sensors. Because microcontroller inputs are digital, analogue sensor voltages must be converted first — usually via a sensor interface such as a Schmitt trigger (covered in the previous lesson) or a comparator circuit, or by using the microcontroller’s own analogue-to-digital converter (ADC) pin if it has one.
  • Output pins drive loads. A microcontroller output pin can typically only supply a few milliamps — enough to light an LED directly, but not enough to drive a motor or relay. For higher-current loads, the output pin switches a transistor or MOSFET, which then drives the load. This is called an output driver stage.

A typical microcontroller system follows this signal path:

Sensor → Interface circuit → Microcontroller input pin → Program → Output pin → Driver → Output device

For example, a light-sensor circuit might have: LDR in a voltage divider → Schmitt inverter (produces clean HIGH/LOW) → microcontroller input pin. The program reads that pin, and if it is HIGH (dark detected), it sets an output pin HIGH → MOSFET gate → motor or lamp. Without the Schmitt inverter, a slowly-rising LDR voltage could put the input pin at an ambiguous logic level, causing unpredictable program behaviour.

Programming with Flowcharts

Microcontrollers are programmed using a flowchart that describes, step by step, what the program does. Flowchart software (such as the Genie environment used with PIC microcontrollers) translates these diagrams directly into the machine code that the chip executes. Each shape in the flowchart has a specific meaning:

Symbol shape Block type What it represents Example
Rounded rectangle (oval) Terminator Start or End of the program “START” / “END”
Parallelogram Input / Output Read an input pin or set an output pin “Read switch A” / “Turn LED on”
Rectangle Process Perform a calculation, count, time delay or arithmetic operation “Add 1 to count” / “Wait 500 ms”
Diamond Decision Test a condition; two exits labelled YES and NO (or TRUE/FALSE) “Is switch pressed?”
Key Fact

This lesson uses four common block types: terminator (rounded rectangle — Start/End), input/output (parallelogram — read or set a pin), process (rectangle — calculate, count or wait), and decision (diamond — yes/no branch). A flowchart begins with Start; use an End terminator only when the program terminates.

Key Flowchart Operations

Flowchart programs can implement six fundamental operations:

  • Input/Output — reading a sensor pin HIGH or LOW; setting an output pin to turn a device on or off.
  • Counting — a process block increments or decrements a variable each time the program passes through it; a decision block tests whether the count has reached a target value.
  • Branching — a decision diamond splits the flow into two paths depending on whether a condition is true or false; the two paths rejoin further down the flowchart or lead to different actions.
  • Testing a condition — asking “Is the input HIGH?” or “Has the count reached 10?” with YES/NO exits.
  • Time delay — a process block that pauses the program for a set number of milliseconds before moving to the next step; used to control flashing rates, wait for a motor to reach speed, or debounce inputs in software.
  • Loop — an arrow that leads back to an earlier point in the flowchart, causing the program to repeat. A loop back to “START” creates a program that runs forever; a conditional loop keeps repeating until a decision condition becomes true.

Specification: when a push-button is pressed, a green LED turns off, a red LED turns on, and after a 5-second delay the green LED turns back on. Repeat forever.

Flowchart sequence:

  1. START (terminator)
  2. Turn GREEN LED on (output block)
  3. Is button pressed? (decision block) — NO loops back to the decision; YES continues.
  4. Turn GREEN LED off / Turn RED LED on (output block)
  5. Wait 5000 ms (process block)
  6. Turn RED LED off (output block) — arrow loops back to step 2 (Turn GREEN LED on).

This flowchart uses all four block types and demonstrates branching, time delay and a repeating loop. In the exam, read the specification carefully before drawing — every condition in the spec should map to a decision diamond and every action to an input/output or process block.

Subroutines

A subroutine is a self-contained block of steps that can be called from several different points in the main flowchart. Instead of repeating the same sequence of blocks every time an action is needed (for example, “flash the LED three times”), the designer draws the sequence once as a subroutine and then calls it with a single block wherever it is needed. Subroutines make flowcharts shorter, easier to read, and simpler to modify. In the exam, if a description says “the alarm sounds for 1 second” and this happens in more than one place in the program, a subroutine is the cleaner solution.

Practice Questions

Test yourself on this lesson. Pick a question, write your answer, then get it marked.

AI feedback
AI feedback is guidance, not a final exam mark. If you disagree, your teacher's view is always the tie-breaker.
← Back to unit
Video

© 2026 StudyVault · About · FAQ · Copyright & IP · Privacy · Disclaimers

StudyVault Education Ltd · registered in England and Wales, company no. 17490559 · 71–75 Shelton Street, London WC2H 9JQ