MadMaker Teacher Workshop






Inputs/Outputs


mcu image


Humans take sensory information as inputs, use our brain to process that information and output back to the environment using our muscles or vocal chords. Naturally occuring systems (senses, brains & muscles) have sythetic counterparts (sensors, MCUs/computers & motors/speakers).




Microcontrollers

When designing devices and robotics, we will often use a tiny computer like device known as a microcontroller (MCU) to control our product, as they can be very small, cheap and more specific for an application. Computers are typically power-hungry multi-taskers which is great for listening to music while playing games and browsing the web but for many real world engineering applications the cost, power and speed of a computer often isn't neccesary!

mcu image


Left: The "surface mount device" (SMD) version is about the width of a fingernail!
Middle: The same MCU is offered in a larger version called dual inline package (DIP), good for prototyping circuits in a breadboard.
Right: Both MCUs are available in development boards. Arduino are a very popular series of development boards which contain various MCUs and pre-made circuits.





Applications


mcu image


Microcontrollers are used all around us in everyday life to control things! Image source





Market


mcu image


By 2022 the MCU market size is predicted grow to over 3.5 million US dollars. Image source




Arduino & The Esplora

The Esplora is an example of an Arduino development board. It comes with a MCU, some sensors (or inputs) and some outputs, already wired together so we can focus on programming it to do things. First we write instructions (code) in human readable language. Computer software like Arduino is used to compile our code, which means translate to machine-language the Esplora understands. More simply, we write instructions for the Esplora and send them from a computer to it using a USB cable. Once the Esplora has instructions or code sent to it, it will act out that code over and over until it loses power.



Specs


mcu image


For inputs there's a joystick, four buttons, a light sensor, a slider, a microphone, a temperature sensor, and an accelerometer. For outputs there's a buzzer and a red/green/blue light emitting diode (or RGB LED. Check out the Esplora Library.




Screen/SD


mcu image


There is an addon screen which also provides an SD card slot. The screen is great for hand held video games and displaying sensor data / user interfaces. The SD card makes data logging a breeze - making it easy to log LOTS of sensor data, maybe classroom temperature of the course of a day, or accelerometer values from a bottle rocket flight.



Storage/Cases


mcu image


The sliders are succeptible to breaking off. It is probably best to store the boards without the cable, maybe in a plastic food container. There is a 3D printable case on thingiverse that protects the slider well however it is quite time consuming and fiddly to print and assemble, It's not recommended unless you're a 3D printing hobbyist and have spare time. Link here. There is a work in progress MadMaker case, design here, or download the STL here. All the parts including the buttons print in place one go and uses three plastic screws to secure the Esplora board. Also worth noting is that the underneath of the Esplora has exposed electrical contacts, if you place the bare board on a metal desk it could short circuit.


Blink

/* Esplora Blink This sketch blinks the Esplora's RGB LED. It goes through all three primary colors (red, green, blue), then it combines them for secondary colors(yellow, cyan, magenta) then it turns on all the colors for white. For best results cover the LED with a piece of white paper to see the colors. Created on 22 Dec 2012 by Tom Igoe This example is in the public domain. */ #include <Esplora.h> void setup() { // There's nothing to set up for this sketch } void loop() { Esplora.writeRGB(255, 0, 0); // make the LED red delay(1000); // wait 1 second Esplora.writeRGB(0, 255, 0); // make the LED green delay(1000); // wait 1 second Esplora.writeRGB(0, 0, 255); // make the LED blue delay(1000); // wait 1 second Esplora.writeRGB(255, 255, 0); // make the LED yellow delay(1000); // wait 1 second Esplora.writeRGB(0, 255, 255); // make the LED cyan delay(1000); // wait 1 second Esplora.writeRGB(255, 0, 255); // make the LED magenta delay(1000); // wait 1 second Esplora.writeRGB(255, 255, 255); // make the LED white delay(1000); // wait 1 second }


Code!

Computer programs like above operate on a line-by-line basis, moving from the first line downwards and executing the instructions on each line as it goes. We call each line a statement, or sometimes an instruction. Statements MUST be ended with a semi column ; .

Variables

Writing code is all about manipulating data, therefore we need a mechanism for storing data, which we call variables, as the value stored can vary over time. To store data into a variable we need to initialise it. To initialise a variable we need to know what type of data we are storing. If we want to store an integer, which is a whole number with no decimal value, we have to specify int, short for integer, as that is the type of the value being stored. If we want to store a decimal, we could use the float type but we are just going to focus on the int type today.


Variables example:

int homer = 11; // declare a new integer, homer set to 11 int marge = 5; // declare a new integer, marge set to 5 homer = homer + marge; // access homer and assign it to 16, 5 + 11

To create the variables homer and marge as integers we use the int keyword. Accessing the variables by printing or assigning later, the int keyword is not needed. If a variable name is on the left hand side of the equal sign, it is being assigned the value on the right hand side of the equal sign. If a variable is on the right hand side of the equal sign that means it is being accessed to possibly be copied into another variable.


Maths

As we just saw, we can use maths operators on our variables. We can use the common mathematical operators on variables and numbers. Here is a table of the operators with examples.




OperatorSymbolUsageMeaning
Add + x + 4; Add 4 to the variable x
Subtract - 5 - y; Subtract y from 5
Multiply * a * i; Multiply a by i
Divide / w/u; Divide w by u




Let's take a look at the control flow of the most simple program. It contains everything you need to compile and upload, even though there are no statements yet so it doesn't actually do anything.


/* This is a block comment that can span multiple lines. It's usually used to give a brief intro to the program and say what it does. */ // This is a single line comment, anything after the "//" is ignored. void setup() { // run once } void loop() { // run forever }


Did I mention we have heaps of tutorial videos on our youtube channel?


Comments

Comments are text that are ignored by the program, they are just there to make something clear to us humans, so we can remember what we were doing, or know what someone else was doing. They can be notes to yourself, or explain what the code does. You can see two different types of comments in the program above, but below is a description of each.

Single line comments:

// this is a single line comment, everything after // is ignored

Multi line comments:

/* This is a multi-line comment it spans between this / * symbole and the * / symbols (without the spaces). You will find these are the top of a program normally, that explain what the program does, and who wrote it. */


Conditionals

In programs, often we want to make decisions based on some input information. For example, if someone is trespassing, then set off the alarm. We can do this with an if statement. For example:

int stock = getCurrentStockLevel; int lowStock = 10; //10 pieces left, time to order more if (stock < lowStock){ orderMoreStock(); }

A conditional statement simply tests whether a statement is true or false. The condition we are checking is the thing inside the brackets. If the answer to the test is true, it will run the lines of code within the curly braces immediately after the statement. If the answer to the test is false, it will skip all the lines of code within the curly braces, and continue on later. Here is a list of conditional statements which are commonly used:


ConditionSymbol
Equal To ==
Not Equal To !=
Greater Than >
Less Than <
Greater Than or Equal To >=
Less Than or Equal To <=




Logical Operators

The logical operators for AND (&&) and OR (||) are used to combine simple relational statements into more complex expressions.


OperatorSymbol
logical NOT !
logical AND &&
logical OR ||




if ((i < 35) || (i > 60)) { // if i < 35 OR i > 60 runThisCode(); if ((i < 35) && (i > 60)) { // if i < 35 && i > 60 runThisCode(); }


Teacher Resourses & Links

The MadMaker Challenge is a free and flexible online course. It is a STEM course with a focus on cutting edge technologies and programming. Solutions to all the problems are available if you are new to programming.
There is an official Challenge/competition period on October 8th for about 6 weeks. During this period we have online tutors that students and teachers can chat to 9-5. There is an optional project based competition in the final few weeks were kids can win prize packs for their school. If you are interested in trialling or partaking in the course, register for a teacher account here. Once you are registered and have clicked on the verification email, send me an email. I will verify you, giving you access to the "teacher dashboard" where you can make a class group, invite your students and then monitor progress in real time.

The MadMaker Coursework is linked to the new Digital Technologies Curriculum. This is detailed here.

This year we implemented automatically graded coding problems.

If you're interested in more info, we have a website here, a FAQ here and mailing list signup here.



Other opportunities at USYD

For more introductory programming courses, The Australian Computing Acadamy (ACA) offer a range of free online, auto-graded STEM courses for K-12! You can view the courses here. The ACA also run the annual NCSS Challenge, which started July 30th. Finally, the ACA host the Grok Learning platform which offer even more STEM and programming courses at a small cost.

Zero Robotics is an international competition for years 9-12 high school students to write code that will control actual robots on the International Space Station! Sydney Uni offers help to schools looking to get involved. Applications have closed for 2018, but 2019 is already fast approaching! More info here!.

Click here for a full list of Sydney Uni STEM related offerings for high school students.



Other STEM opportunities

Here are some links courtesy of Google:

Classroom materials:

CS FIRST: free & open source
CS Unplugged: free & open source
Computational thinking recourses: from Google + partners
Start with Code: resources for parents, teachers & students
Code.org: Scratch and Hour of Code resources
MIT App Inventor: free introduction to programming and app creation

Coding clubs/organizations:


FIRST Australia: STEM & robotics programs from grade 2-12 - nationally run
Code Club Australia: code clubs & information/material to set one up
Code Club Aotearoa: code clubs & information/material to set one up (New Zealand)
Robogals: promoting STEM education to girls

Careers Information:


Careers with Code: free online resource highlighting CS + X careers and university pathways

Teacher PD opportunities:


Digital Technologies MOOCs: from Adelaide University (free online courses, mapped to the Australian Digital Technologies Curriculum for teachers from grades K-8.)

Online Communities:


AU/NZ teachers: an online community of teachers who share resources

Diversity Engagement resources:


Engage CS EDU: resources for use in the classroom & best practices for inclusive teaching developed by Google and NCWIT

Unbiasing: resources to raise unconscious bias in the workplace & for individuals. Includes Google’s internal training & free workshop material

Processing!

Processing is an app which makes it really simple to write software like apps and games! But also it will help us visualise the Esploras sensor information to the screen. is similar in coding style to Arduino. However, the Arduino software uses code to program the Arduino boards and tell them how to function. Processing uses code to draw real time graphics like this:


It is recommended to download the Processing IDE to compile code but for now to save time we are going to run some sketches here in the browser using ProcessingJS. You definetely need the Processing IDE to get the Arduino Esplora to communicate with Processing which we cover in the MadMaker coursework. The control flow is very similar to Arduino except loop is replaced with draw. Both have the same looping functionality. Let's run some code!


ellipse(20,20,50,50); rect(20,20,50,50);


Output:



Outro!

Next Steps

You may want to jump straight to controlling processing apps using the Esplora, but I would urge you to go over the basics mentioned above until you feel confident, then go on to learn about arrays and for loops to be ready to understand the way Esplora and Processing communicate. However, if you're keen to see the communication between the Esplora and processing in action, upload the following code on the left to the Esplora and run the code on the right in Processing.



What you should see is a readout of alllll of the sensors of the Esplora in real time. This is quite interesting to see! Here is Dr Karl enjoying the code below in action!





#include <Esplora.h> void setup() { Serial.begin(9600); } void loop() { int slider = Esplora.readSlider(); int temp = Esplora.readTemperature(DEGREES_C); int mic = Esplora.readMicrophone(); int light = Esplora.readLightSensor(); int joystickx = Esplora.readJoystickX(); int joysticky = Esplora.readJoystickY(); int button = Esplora.readButton(SWITCH_DOWN); int x_axis = Esplora.readAccelerometer(X_AXIS); int y_axis = Esplora.readAccelerometer(Y_AXIS); int z_axis = Esplora.readAccelerometer(Z_AXIS); // print all sensors to Serial monitor on 1 line with a comma in between Serial.print(slider); Serial.print(","); Serial.print(temp); Serial.print(","); Serial.print(mic); Serial.print(","); Serial.print(light); Serial.print(","); Serial.print(joystickx); Serial.print(","); Serial.print(joysticky); Serial.print(","); Serial.print(button); Serial.print(","); Serial.print(x_axis); Serial.print(","); Serial.print(y_axis); Serial.print(","); Serial.print(z_axis); Serial.println(); delay(20); }
import processing.serial.*; // import the Serial library String serial; Serial port; int spacing = 50; int offset = 60; static int lf = 10; // Setup the serial connection. void setupSerial() { printArray(Serial.list()); //String comPort = Serial.list()[0]; // should work on linux String comPort = Serial.list()[Serial.list().length-1]; // select the last one, windows and mac try { port = new Serial(this, comPort, 9600); port.bufferUntil(lf); } catch (Exception e) { println(e); println("Exiting! Serial port error! Make sure you choose the correct serial port in the list."); exit(); } } // read the serial port, and update the radius global veriable if the input is an integer void serialEvent(Serial port) { serial = trim(port.readString()); // read the serial line and remove whitespace and extra characters try { serial = trim(serial); String[] a = split(serial,','); // ignore the RGB: at the beginning, and split the rest where there is a , if (a.length >= NUM_SENSORS) { for (int i = 0; i < NUM_SENSORS; i++) { esplora[i] = int(a[i]); } } } catch (Exception e) { println("Wrong type of data, please check you are sending 3 integers separated by a comma and try again"); exit(); } } // Number of sensors read from Esplora int NUM_SENSORS = 10; String[] sensors = {"Slider","Temperature","Microphone","Light","Joystick x","Joystick y","Button down","x acceleration","y acceleration","z acceleration"}; // save the sensors in an array called esplora int esplora[] = new int[NUM_SENSORS]; void setup(){ setupSerial(); size(500,600); // size of window fill(255); textSize(32); textAlign(CENTER, CENTER); } void draw(){ background(0); String text = ""; for(int i = 0; i < NUM_SENSORS; i++) { text(sensors[i] + " : " + esplora[i], width*0.5, offset+i*spacing); } }