Home automation programming (Yrs 5-6)
About this lesson
Investigate home automation systems, including those powered by artificial intelligence (AI) with speech recognition capability. These suggested activities provide a level of differentiation to cater for students’ range of programming skills. They were developed in collaboration with the Digital Technologies Institute.
Year band: 5-6
Curriculum Links AssessmentCurriculum Links
Links with the Digital Technologies Curriculum Area.
Year | Content Description |
---|---|
Years 5-6 |
Explain how digital systems represent all data using numbers (AC9TDI6K03) Design algorithms involving multiple alternatives (branching) and iteration (AC9TDI6P02) Implement algorithms as visual programs involving control structures, variables and input (AC9TDI6P05) Evaluate existing and student solutions against the design criteria and user stories and their broader community impact (AC9TDI6P06) Investigate the main internal components of common digital systems and their function (AC9TDI6K01) Examine how digital systems form networks to transmit data (AC9TDI6K02) Design a user interface for a digital system (AC9TDI6P03) Select and use appropriate digital tools effectively to create, locate and communicate content, applying common conventions (AC9TDI6P07) Select and use appropriate digital tools effectively to share content online, plan tasks and collaborate on projects, demonstrating agreed behaviours (AC9TDI6P08)
|
ICT Capability
Typically, by the end of Year 6, students:
Apply digital information security practices
- Independently apply strategies for determining and protecting the security of digital information and assess the risks associated with online environments
Apply personal security protocols
- Identify the risks to identity, privacy and emotional safety for themselves when using ICT and apply generally accepted social protocols when sharing information in online environments, taking into account different social and cultural contexts
Assessment
Teacher assessment
Choose from these suggested assessment approaches and tasks those that will best suit your students.
Possible tasks | Relevant content description(s) |
---|---|
Describe the data required and stored in the program controlling /automating the appliances. What digital systems are used to transmit the data? | AC9TDI6K03 |
Draw a representation of the algorithm for your program. Explain how it works. What data is used and stored? |
AC9TDI6P02 |
For those that created an AI model using Machine Learning for Kids, capture a video of the program in action. Demonstrate how well the voice commands were recognised by the AI and describe the related output automating the appropriate appliance. |
AC9TDI6P05 |
This type of AI uses speech recognition. How is this type of AI used in our daily lives? List some examples. How would you prefer this type of AI be used? What issues might arise? |
AC9TDI6P06 |
Learning sequence
Download LessonPreliminary notes
Text to speech blocks enable a user to include speech into their Scratch projects. It recognises text input into the program and speaks the words.
To program using Text to Speech blocks, access the additional blocks available in Scratch 3.0 project editor.
Note: It is advised that students use the desktop version of Scratch. This version of Scratch does not require a log in or any functionality to comment on or share projects.
Before using any new technology tools undertake a risk assessment using the eSafety Commission’s New Technology: Risk assessment.
Image: Screen capture of Machine Learning for Kids Scratch 3.0 program editor showing Speech to Text blocks
Test Text to Speech set-up
Create this simple script to test the Text to Speech to Text functionality. Add the Text to Speech blocks by selecting the blue Add extension at the very bottom of the code blocks (see it in the screen capture above):
Suggested steps
Unplugged activity
Discuss home automation. Ask, ‘How might voice commands be used in home automation?’ Consider aspects of home automation such as:
- security and access
- climate control
- lighting
- entertainment.
Discuss the role of AI in performing the automation. This may prompt students to mention the use of personal assistants.
Ask students to consider how home automation can or might assist those living with disability.
With new technologies there are often risks to consider. Ask what could go wrong. Discuss risks such as privacy breaches from a system being hacked or times when the system might be down due to a power outage (including one caused by a natural disaster such as fire or flood).
Plugged activity
Use these suggested activities to explore implementing a digital solution that demonstrates how to control appliances, and to further investigate home automation.
Use binary numbers 0 and 1 to switch a light on and off (skill level: easy)
Use Scratch 3.0 or a similar visual programming language (without any form of AI) to create a program that switches appliances on and off using an input: 0 or 1. This task demonstrates the use of binary digits to change state; for example, ‘On to off’ or ‘Off to on’. As this program does not use any form of AI, use it to demonstrate how conventional coding is used to hard-code a particular action.
Depending on students’ familiarity with and understanding of binary numbers, review the use of 0 and 1 and explain that binary means ‘two states’. The two states can be represented in different ways, such as by the numbers 1 and 0, or by text (‘true’ and ‘false’, or ‘on’ and ‘off’). The main point here is that a binary device can be in just one of two possible states. A binary bit is a single on/off value.
Cover image credit: mcmurryjulie/ Pixabay
Abstraction is all about focusing on important information and excluding non-essential information. In this example of an electrical toggle switch, features such as size, colour, and placement are not essential for our purpose. The important information is that it operates in two states: on and off. The switch has many different representations: binary digits (1/0), text (on/off), true/false, or visually, as an electrical symbol. Here is an example of that, showing ‘Switch off’:
Suggested steps
- Students consider a home appliance they want to include in their program, for example a light or fan, then create the appliance as a sprite. Free versions of icons can be found online, saved to a folder and uploaded, or students can draw their own.
- Initiate each sprite using the block ‘when (green flag) clicked’.
- Use an ‘ask’ block to enable the user to input a 0 or 1.
- Use an if/then block to instruct what happens if ‘0’ is input.
- Use a second if/then block to instruct what happens if ‘1’ is input.
I
In the two-part example below, the sprite (light) changes costume (has a yellow fill) to show an illuminated light.
Image: Screen capture of Scratch 3.0 program giving user instructions for using either 0 or 1 as input
Image: Screen capture of Scratch 3.0 program showing if/then blocks based on user input answer (1), to turn light on
For sample code, see Binary switch light on/off.
Students:
- create their own sprites for other appliances
- add a block of program code that turns each appliance on and off
- add a block of program code that controls multiple appliances
- change backgrounds
Use text to speech recognition in your program to switch appliances on and off (skill level: medium)
Text to speech blocks enable a user to include speech into their Scratch projects. It recognises text input into the program and speaks the words.
To program using Text to Speech blocks, access the additional blocks available in Scratch 3.0 project editor. Present the challenge of creating a program that recognises a text input and speaks the words entered to perform an action such as turning home appliances on or off.
Discuss the types of voice commands that might typically be used, for example:
- Turn on/turn off
- Lights on/Lights off
- Turn fan on/Turn fan off.
Emphasise short commands that are easy to understand.
Suggested steps
- Students consider a home appliance they want to include in their program, for example a light or a fan, and create it as a sprite. Free versions of icons can be found online, saved to a folder and uploaded, or students can draw their own.
- One way to program the Virtual Assistant to control the appliances is to have a sprite say the instructions and the virtual assistant follows the commands.
Select a character (sprite) to ask what you want to turn on or off. The use of an ask block enables text input by the user. The answer can be shown on screen and using a speak block, said by the sprite.Image: Screen capture of Scratch 3 program, showing sprite (Abby) asking what she should tell the virtual assistant to add.
- Code the light (sprite) to turn on and off. Use an if/then block and the operator block (apple contains a) which recognises a key word in a string of text. Add the 'answer' block in green block and type in ‘on’. So if the answer (text entered) contains ‘on’ then the sprite will switch costume (to the animated costume). Students can duplicate blocks and change contains off and change costume to off costume.
Image: Screen capture use of Scratch 3 program, showing the use of if then blocks, operator blocks and a forever block
- If students add another appliance they will need to modify the code to include the name of the appliance AND either on or off. Otherwise the program will turn on more than one appliance. The AND operator is needed.
Image: Screen capture use of Scratch 3 program, showing joining two operator blocks
Provide this sample code for students to remix.
Students:
- create their own sprites for other appliances
- add a block of program code that turns the appliance on and off based on the light example
- change backgrounds.
Discussion
Share what you have learned about AI and how ‘smart’ a computer can be. Think about the program you created:
- What were some of the challenges?
- Where the program used AI to recognise the text and speak the words, what things affected how well it worked?
- How might you improve the program if you did the task again?
Why is this relevant?
Algorithms and programming are essential to developing machines powered by artificial intelligence (AI). AI is the ability of machines to mimic human capabilities in a way that we would consider 'smart'.
In conventional programming the computer is provided with a set of instructions for a defined set of scenarios. In the binary program, the students hard-coded the program with specific inputs of 0 or 1 to turn the appliance off/on. To include a trained AI models to recognise text and speak the commands as ‘turn on’ or ‘turn off’ for each appliance.
Machine learning (ML) is an application of AI. With machine learning, we give the machine lots of examples of data, demonstrating what we would like it to do so that it can figure out how to achieve a goal on its own. The machine learns and adapts its strategy to achieve this goal.
This lesson focuses on:
- binary numbers (1, 0)
- speech recognition
- training an AI with suitable data.
Resources
- Visual programming environment Scratch 3.0
- Home automation sample code