Unit 6 — Master the programming process, Scratch, App Inventor, flowcharts and artificial intelligence.
Writing lines of code (instructions) to make a program or application that solves a problem or satisfies a need. We use an artificial programming language designed to give instructions to a machine with a microprocessor.
Integrated Development Environment. A tool that lets us type instructions, compile them, translate them into machine code and run the program. Examples: Visual Studio Code, Scratch, App Inventor.
JavaScript, Java, Python, C++, Visual Basic… Each has its own vocabulary and rules. The right choice depends on the task: a video game, an antivirus and a self-driving car each require a different approach.
Define the problem / identify a need. Be clear about the exact problem, the available data, and how you will present the solution.
Analyse and solve the problem. Investigate how to make the machine work with the data. Choose the most suitable programming language and study the parameters, operations and algorithms needed. Represent the logic as a flowchart.
Programming. Use the chosen language to write the actual code.
Checking and debugging. Test the program against the requirements from step 1. Fix any errors (bugs). Share if it works!
A finite, ordered set of steps that solves a problem. It must have a clear start and end, and each step must be unambiguous.
A visual diagram that represents an algorithm using standardised shapes connected by arrows.
Tool recommended: Flowgorithm (free, online) — draw the flowchart and it automatically generates code in several languages.
| Shape | Meaning |
|---|---|
| Oval ⬭ | Start / End |
| Rectangle □ | Process / action |
| Parallelogram ▱ | Input / Output |
| Diamond ◇ | Decision (Yes / No) |
| Arrow → | Flow of control |
A shop sells apples at €1.20/kg. Discount of 10% if over 3 kg. Calculate total price. → Data, Operations, Result.
480 × 360 px canvas where action happens. Coordinate centre at (0,0).
Objects / characters on the stage. Each has its own routines (code).
Background images for the stage. Choose from library or create your own.
Colour-coded blocks organised by category: Motion, Looks, Sound, Events, Control, Sensing, Operators, Variables.
Each Sprite can have multiple costumes for animation effects.
Drag and drop blocks here to write the program routines.
Containers that store data — numbers, names, text — used throughout the program. In Scratch: Make a Variable in the Variables palette.
Perform arithmetic (+, −, ×, ÷), generate random numbers, and check if data is correct (comparisons, boolean logic).
Run a set of instructions only when a condition is met. Found in the Control tab. Structure: if … then … else …
Repeat a set of instructions a given number of times or until a condition is met. Types: repeat n, forever, repeat until.
A game where a diver collects plastic while avoiding a shark. Requires: a backdrop (ocean), 3 sprites (Diver, Shark, Plastic), a forever loop for the shark, conditionals for collision detection, and a variable for score.
A catching game with a Cat sprite, falling Fruit and Cake sprites, a score variable, a FruitBasket list to track collected items, and routines for keyboard control, costume change, scoring and game-over detection.
scratch.mit.edu — free, browser-based, no installation needed. Sign in to save and share projects.
A free online tool by MIT for designing and developing apps for Android devices. The programming approach is block-based, very similar to Scratch. Access at ai2.appinventor.mit.edu
| # | Area | Function |
|---|---|---|
| 1 | Menu toolbar | Manage projects, set language |
| 2 | Window toolbar | Shows project name, controls windows |
| 3 | Palette | Components to build the app (by category) |
| 4 | Viewer | Preview the app layout on screen |
| 5 | Components | List of elements added to the app |
| 6 | Media | Upload images, audio and video |
| 7 | Properties | Set font, location, background, image… |
All program blocks organised by type: Control, Logic, Maths. Colour-coded like Scratch.
Drag and combine blocks here to write the program logic.
Drag blocks here to delete them.
Build → Generate QR code (.apk) → scan with your Android phone using the MIT AI2 Companion app. No cable needed.
Problem: Create a simple app for children that shows a farm. Each animal makes its sound when touched.
Design: A Canvas (like Scratch's Stage). Two ImageSprites (Sheep, Hen). Background: Farm.jpg. Sound files: baa.mp3, cluck.mp3.
Key block: when ImageSprite1.Touched → do call Sound1.Play
Testing: Check, correct errors. Deploy with Build → QR code.
Problem: A quiz game showing famous regional monuments. 4 answer buttons + a Next button.
Key components: Image1 (monument photo), Label Question (question text), HorizontalArrangement1 (button row), RightWrong label (feedback), Next button.
Variables used: listofQuestions (ordered list), listofAnswers, listofPictures, questionNumber (tracks current question).
Next button logic: Clear RightWrong text → increment questionNumber → if end of list, reset to 1 → update Question label and Image.
Lists (like arrays) store ordered data. Use select list item list … index … to retrieve a specific item. Lists are essential for quiz apps, databases and catalogues.
A free browser-based tool (blockscad3d.com/editor) that uses blocks to design 3D parts — directly exportable for 3D printing. It bridges programming logic and physical fabrication.
Basic shapes: sphere, cylinder, cube. Combined with boolean operations (union, difference, intersection).
Use repeat loops to generate arrays of objects — e.g. 10 LED lens epoxy rings automatically spaced.
Click Render to see the final 3D object. Export as .STL for 3D printing.
Base cylinder (r=2.9, h=1.0) → subtract offset cube for notch → add central cylinder → incorporate sphere (r=2.5, z=6.2). The program uses difference() and union() operations — the same logic as code conditionals.
Data: What inputs does the algorithm need?
Operations: What calculations or decisions are needed?
Result: What should the output be?
Price €1.20/kg. 10% discount if >3 kg. The flowchart has one diamond decision block: "weight > 3?" → YES branch applies discount, NO branch does not.
Flowgorithm lets you run the flowchart step-by-step AND export it as Python, Java, C++, etc. — a great bridge between visual logic and text code.
A simulation of pandemic spread using Scratch's create clone of… block, a data variable called infections, and a stopwatch to measure infection rate over time.
Healthy, Infected, Line, Tracker — four objects with different costumes.
Create 50 clones (kittens). If a Healthy clone touches an Infected one → create new Infected clone, infections += 1.
A list called data records infections every 2 seconds. Export to spreadsheet for analysis.
infections (integer counter), stopwatch (built-in Scratch timer). Condition: mask or no mask changes infection probability.
This is computational modelling — the same principle used by scientists to model real epidemics. Changing the mask condition is equivalent to changing a parameter in a real scientific model. Data collected can be analysed in Google Sheets or LibreOffice Calc.
The intelligence that machines possess: the ability to perceive their environment, reason, communicate and learn. AI programs don't know exactly what to do with data — they must work it out by themselves by learning patterns from examples.
A branch of AI where the computer learns from labelled examples instead of following fixed rules. Used in image recognition, language translation, spam filters.
A type of machine learning using neural networks (layers of algorithms inspired by the human brain). Powers virtual assistants, autonomous vehicles.
Everyday objects equipped with sensors that send data to the cloud. Smart thermostats, connected waste containers, wearables.
A real project: smart bins that use AI + IoT to predict waste volume and optimise collection routes, reducing fuel use and pollution.
Choose the input type: Text, images, numbers or sounds. For the waste classifier, choose text.
Create labels (classes): e.g. "Paper", "Plastic", "Glass", "Organic", "General". These are the categories the AI will learn.
Add training data: Write as many examples of each type as you can. Try for an equal number of examples per label.
Train the model: Click Train. The algorithm finds patterns in your examples.
Learn & Test → Make: Test with new inputs. If the model makes mistakes, add more training data for that class and retrain.
Import into Scratch: New ML blocks appear in the palette. Use them in your game to classify waste in real time.
A Scratch game where waste falls from the top and the player places it in the correct bin. Connect the ML model so that the AI classifies the waste automatically. Add a scoreboard and a list of waste collected per bin.
Sensors predict irrigation needs. Drones control plantations and detect pests. Autonomous robots perform agricultural tasks.
Predict energy needs and optimal conditions for wind/solar production. Reduces waste and improves grid efficiency.
AI vision systems at recycling centres classify waste faster and more accurately than humans.
Autonomous vehicles optimise traffic flow. AI proposes alternative routes to reduce jams and CO₂ emissions.
Satellite image analysis detects vegetation changes, water shortages, and invasive species early.
Chatbots assist elderly people. AI analyses biological big data to predict and prevent diseases.
Loss of jobs, high energy demands to train large models, tendency to reflect the biases (race, gender, age) of their creators through discriminatory data. Critical thinking about AI systems is a key digital competence.
Products deliberately designed to fail or become unfashionable quickly → drives over-consumption. Part of the linear take-make-waste economy.
Keeps materials in use as long as possible. Goal: zero waste, zero pollution, nature regeneration.
Refuse → Rethink → Reduce → Reuse → Repair → Refurbish → Remanufacture → Repurpose → Recycle. In that priority order.
Minimise single-use plastics. Reuse packaging. Buy in bulk. Before recycling, reduce — recycling still costs energy and materials.
Wind and solar are variable. To achieve climate neutrality, we need to store energy for when it's needed — not just when it's produced.
| Technology | How it works | Scale |
|---|---|---|
| Batteries | Chemical reactions between two electrodes + electrolyte. Li-ion: phones, EVs. Ni-MH: electronics. LiPo: higher energy density. | Small–large |
| Graphene supercapacitors | Charge in seconds, high power output. Miniaturised for wearables and IoT. | Micro–medium |
| Superconducting magnets | No energy loss — but need cryogenic temperatures. | Large |
| Pumped hydro | Water pumped uphill when surplus energy; released to generate electricity on demand. Most common in Europe. | Grid-scale |
| Compressed air | Store compressed air in containers; release to power generators. | Grid-scale |
| Thermal storage | Store heat or cold; convert back to electricity. | Large |
| Hydrogen | Basis of fuel cells. Produce via electrolysis using renewable electricity. Energy-dense but requires renewable source. | Grid-scale |
Activities marked ★ Extended can form part of the project portfolio. Always document your process: problem definition, design decisions, testing evidence and conclusions.
Choose one of the following problems and design a complete flowchart using Flowgorithm or on paper:
(a) A program that asks for a student's mark (0–10) and outputs: Fail (<5), Pass (5–6), Merit (7–8) or Distinction (9–10).
(b) A program that calculates the area of a circle given the radius, applying a 15% surcharge if area > 50 m².
Export the Flowgorithm diagram and auto-generate the code in Python. Compare the flowchart and the code side-by-side in a brief written reflection.
Recreate (or extend) the "Cleaning up our oceans" game from the unit. Requirements:
· Diver sprite controlled by arrow keys (Diver routine).
· Shark sprite that always follows the diver (infinite loop + point towards).
· Plastic sprite that loops continuously with a new random costume on each cycle.
· Score variable: +1 per plastic collected. Game ends when shark touches diver.
Extension: Add a timer variable and display it on screen. Add a high-score system using a list.
Open the pandemic simulation from the unit (or recreate it). Run the simulation three times: (1) no masks, (2) 50% mask usage, (3) 100% mask usage. Export the infections data list each time. Import into Google Sheets, create a line chart overlaying the three scenarios, and write a 150-word analytical conclusion: How does mask adoption affect peak infections and infection rate? What real-world policy implications does this suggest?
Build your own quiz app about a topic of your choice (history, science, geography of Murcia…). Requirements:
· Minimum 8 questions stored in a listofQuestions.
· Corresponding lists for answers and images.
· RightWrong label gives immediate feedback.
· Score counter visible on screen.
· At the end, a screen showing final score and option to restart.
Deploy to a real Android device using QR code. Record a short screen-capture demo video.
Using machinelearningforkids.co.uk, train a text-based classifier with at least 5 waste categories (Paper, Plastic, Glass, Organic, General) and 15+ examples per class. Test your model's accuracy. Then integrate it into a Scratch game where:
· Waste items fall from the top of the stage.
· The player types or clicks the correct bin.
· The ML model checks whether the waste type matches the bin.
· A scoreboard and end-of-game waste summary list are shown.
Document the ML training process with screenshots.
Design a functional 3D object in BlocksCAD using at least 3 primitives (cylinder, cube, sphere), at least one boolean operation (difference or union), and at least one loop (e.g. to repeat a pattern). Suggested objects: custom pen holder, a set of chess pawns, a parametric bracket. Export the .STL file and, if possible, prepare it for slicing with PrusaSlicer or OrcaSlicer. Write a brief design journal explaining each step and the programming logic used.
Choose 5 electronic products you use regularly (phone, laptop, headphones, game console, tablet). For each, research:
(a) Planned obsolescence indicators (how long until it's unsupported/breaks?).
(b) Repairability score (check ifixit.com).
(c) Which of the 9 R's applies when it reaches end-of-life.
Present your findings in a Google Slides deck (1 slide per product). Conclude with a class-wide sustainability ranking and three actionable recommendations.
12 questions covering all sections of Unit 6. Select your answer — immediate feedback is given. Check your total score at the bottom. Each question has only one correct answer.