In our first unit we learn the basics of defining and calling functions, providing input parameters and return output values. And we define and describe the algorithms to solve our problems. Rearranging program code to become modular makes it easier to reuse code and reduce errors.

YouTube Video (1:52) - Although we hear about the negative sides of automation in today’s world, learning how to use automation ourselves is essential to seeing how it can be a force for good. In this first video of the automation course this year, I want to share some of the reasons why I am optimistic about what we are going to learn this year.
For this task, there are three tools you can explore how to build your own automated solutions to problems you face. You can choose any of them. Here are three videos describing how to build with each one:
Your task for the next class is to experiment with any of these tools to get a sense of how they work. Feel free to look for other tutorials out there to help you with any questions that might arise.
You must then build your own two automated tasks with any of the tools above. You should be prepared to explain the background context and the steps in the automation you build. Submit a single screenshot for each program in the assignment below.
YouTube Explanation (6:08) - Last week we started looking at ways to break tasks down into individual steps. This video formalizes this using the programming concept of a function. You’ll learn some vocabulary of functions and ways to describe them using inputs, outputs, and how they relate to each other through algorithms.
YouTube Video (10:43) - Using what I showed you in the last video, we take a look at code for my Gmail Auto-reply script and analyze functions for inputs, outputs, and algorithms. I show a few examples and leave the rest for you to do with your team. Along the way, we learn a bit about arrays, the logical OR operator, and some other elements of Javascript.
Template for Analysis - and assignment in Schoology
This is microbit/shockdetector.js
Accounts for Collaboration in Advanced Automation
Following the style of what I did in the first video of breaking down the Shock Detector task, choose one of the problems mentioned in class and break it into a series of functions that each achieve a specific sub-task. For each function, identify the inputs and outputs to the extent that you can.
Template for students to copy and fill in ** Standard 3 formative
In this skill-building activity, you will follow along with the video below to convert a single program into modular code organized into functions
This is microbit/modularCodeExampleStart.js
Students create modular code and submit it. The code and description will be graded in the standards 1 and 3.

Review of global and local variables in https://makecode.microbit.org/ Example code: https://makecode.microbit.org/_PMgfmrJg31tw
Reflect on the 3 stages when making a cup of coffee:
myDrinkMachine.startFillingContainer()myDrinkMachine.addGrounds()myDrinkMachine.turnHeaterOn()Students submit the code that generates two of the drinks from the list as assigned from class.
Now that you’ve played with Drink Machine and have done some things the long way, Mr. Weinberg is showing the better ways than the wait times and further details:
if/then/switchCopy the code from the following link into your program. It looks like this:
input.onButtonPressed(Button.A, function () {
serial.writeLine("I start to make __specification-A__")
// call your function here
})
input.onButtonPressed(Button.B, function () {
serial.writeLine("I start to make __specification-B__")
})
// You can use the degree symbol ˚C in your specification
serial.writeLine("Press A for __specification-A__ and B for __specification-B__")
After pressing Button A and B it should generate the assigned drink. Assignments are done using the following programs:
For this project the code is project/drinkmachine.js