Page 1

Kids, Code, and Computer Science What Is FizzBuzz? Making Triangles With Python

s e m a G r e y a ? l k r p o i t W l y u e h M oT D w o H

February 2019

$6.00 $6.00 USD

New Feature! Check out “In the Middle"


beanz magazine February 2019: Volume 6 Issue 4 Issue 40 (online) & 25 (print) ISSN: 2573-3966 (online) ISSN: 2573-3958 (print) beanz Magazine© is published bi-monthly, six times a year, online at http://beanzmag.com and in print. A print + online magazine subscription includes online access to all articles, with links to let you explore topics in more detail. SUBSCRIBE: visit http://beanzmag. com/subscribe or email us for checks/ invoices. We’re also available through EBSCO, Discount Magazine, WT Cox, Magazine PTP, and many other subscription services. ONLINE MAGAZINE ACCESS: send your email address to hello@beanzmag.com and we’ll set you up. Published by Owl Hill Media, LLC 378 Eastwood Rd, Woodmere, NY 11598 Email: hello@beanzmag.com Phone: (646) 553-3390

Publisher’s Note It always amazes me, when I look over the list of stories before writing this note, how many different kinds of stories are in each issue of the magazine. In this February issue, we have a story with ideas for creating lanterns for the Chinese lantern festival and 3D printing ideas for Valentine’s Day. We also have articles about telling stories in Minecraft and Scratch, how multiplayer games really work, Python projects, file systems, and a project to build a circuit board with cardboard and copper slug tape. Tidbitz also mentions articles about visiting ancient Rome online and watching the earth as it rolls under the International Space Station. There’s also an interesting artificial intelligence problem called the Paperclip Maximizer, which shows the limits of AI. Paperclips can be dangerous, believe it or not. And there’s an interesting article on the inside back cover about the value of "useless robots." We often learn more by repeatedly trying and failing! This issue also introduces a two-page feature in the center of the magazine called "In the Middle", to explore technology and history in depth. This time, we show how modern cars use computers and networks to operate. Future issues will explore the history of robots and batteries and other neat technology stuff. Hope you enjoy the issue!

POSTMASTER: Send address changes to Owl Hill Media, LLC, 378 Eastwood Rd, Woodmere, NY 11598. Periodicals postage paid at Woodmere, NY and other mailing offices Copyright Owl Hill Media, LLC with all rights reserved except as noted. Images are copyrighted by their creators, as noted with each story both online and in print. Publisher/Editor/Webmaster: Tim Slavin Staff Writers: Amy S. Hansen, Simon Batt, Patricia Foster, Bonnie Roskes, Clarissa Littler, Jennifer Newell, Les Pounder, Paul Seal, Erin Winnick, Tim Slavin Contributors: David Dodge, Jay Silver, Jeremy Kubica, Colleen Graves, Daniel Fenjves, Ali Hagen, Emeline Swanson, Jean-Francois Nguyen, Madeleine Slavin, Tim McGuigan Back Office Magic: Wendy Garrison Copy Editors: Eileen Seiler Art Director: Kelley Lanuto Webmistress: Patricia Foster COVER IMAGE: ANNA SAMOYOVA, UNSPLASH

Tim Slavin Publisher beanz Magazine beanz magazine (as Kids, Code, and Computer Science magazine, our earlier title) is a winner of Parents’ Choice, Tillywig, and Academics’

Our Mission

Choice awards: http:// beanzmag.com/awards

beanz magazine is a bi-monthly online and print magazine about learning to code, computer science, and how we use technology in our daily lives. The magazine includes hard-to-find information, for example, a list of 40+ programming languages for education, coding schools, summer tech camps, and more. While the magazine is written to help kids ages 8 and older learn about programming and computer science, many readers and subscribers are parents, teachers, and librarians who use the articles to learn alongside their young kids, students, or library patrons. The magazine strives to provide easy to understand how-to information, with a bit of quirky fun. Subscribers support the magazine. There is no advertising to distract readers. The magazine explores these topics: Basics of programming and where to learn more, Problem solving and collaboration, Mathematical foundations of computing and computer science, Computational thinking, Recognizing and selecting computer devices, and the Community, global, and ethical impacts of technology.


contents

advanced

intermediate

beginner

scribe b u s / m ag.co m z n a e b http://

February 2019 Cover Story

20

12

Tech in Real Life What Cell Tower?

2 4 5 6 7

14

Coding Cover Story What Is FizzBuzz? Secret Codes Getting Past the Man in the Middle Concepts The Paperclip Maximizer Concepts File Systems Languages C

Best Practices Multiplayer Games

8 9 10 13 16

In the Middle Computers... in Cars? Cover Story

tidbitz

11 Say My Name 11 When in Rome 11 What in the World?

17 18 22

Minecraft Telling Stories in Minecraft Concepts Requests and Responses SketchUp It's All Blurry!

Projects Cover Story Python Triangles Events Thanks, USO! Notebook Lantern Festival Projects I Love This! Scratch Telling Stories in Scratch

24

Electronics Build Your Own Circuit Board

27

Projects TIC-80: Adding Screens to Your Platformer

28

Parents and Teachers The Case for Useless Robots

 Wait... what?


Coding

2

BY PATRICIA FOSTER

What is FizzBuzz?

Your challenge is to print out a list of numbers from 1 to 100. Every number divisible by 3 must be replaced by the word ‘fizz’, and every number divisible by 5 is replaced by ‘buzz’. If the number is divisible by both 3 and 5, then replace it with ‘fizzbuzz’. It’s a simple problem with many solutions, from the quick and easy to the complex and elegant. In computer geek circles, ‘FizzBuzz’ is a classic puzzle that pops up time and time again. Companies even ask it to candidates during coding job interviews! How would you approach the code? What hurdles could you hit? What coding structures can you pull out of your arsenal? A Simple Solution

The piece of code that makes things simple is the modulus operator, which you write as “%” and say out loud as “mod”. It’s a mathematical operator, like +, -, or *, and it tells us how much is leftover after a division. Remember how we did divisions before learning about decimal numbers? So if: 15/6 = 2 (with a of remainder of 3) THEN 15 % 6 = 3 Likewise: 7/3 = 2 (with a of remainder of 1) THEN 7 % 3 = 1 When a number is perfectly divisible by another, then the mod operator always returns 0. 9/3 = 3 (no remainder) SO 9 % 3 = 0 Likewise: 10/5 = 2 (no remainder) SO 10 % 5 = 0 As a rule of thumb, when you need to check divisibility in a program, use the modulus operator. Now, let’s take a look at this simple solution to FizzBuzz, written in Python: for num in xrange(1, 101): # for all numbers from 1 to 100 if num % 3 == 0 and num % 5 == 0: print("fizzbuzz") elif num % 3 == 0: print("fizz") elif num % 5 == 0: print("buzz") else: print(num) Try it out for yourself! You can download a free IDE like PyCharm (https://www.jetbrains.com/pycharm/ download/#section=windows) or use an online website like repl.it (www.repl.it/languages/python3) to run the code. (See example, page 3.) In our program, we loop through all the numbers between 1 and 100. For each number, we check if it’s divisible by both 3 and 5, in which case we print ‘fizzbuzz’. Next, we cover the cases where it’s only divisible by one number. Finally, our “catch all” else statement handles the numbers that are not divisible by 3 or 5, which are printed normally. Our code does the job. But does it do it well? Best Practices

Code can be judged on three criteria: 1. EASY TO READ. If someone is unfamiliar with our program, how easy is it to read and understand? 2. SPEED. Are there any unnecessary operations? Do we repeat things we don’t have to? 3. FLEXIBILITY. If we want to modify our program, how easy is it to add or remove features? Our FizzBuzz program is definitely easy to read. In terms of efficiency, a few tweaks will make it faster. For example, the same mod operation is done multiple times. What if we combine them? RAWPIXEL, UNSPLASH


3 for num in xrange(1, 101): # for all numbers from 1 to 100 fizz = (num % 3 == 0) buzz = (num % 5 == 0) output = "" if fizz: output += "fizz" if buzz: output += "buzz" if output == "": output = num print(output) On the plus side, our operations no longer repeat, but on the down side, the code is morphing into something obscure and bizarre. Is the second snippet better? This isn’t a universal “yes or no” answer; it depends on the goal of your software. If you’re writing code for an embedded microchip, you probably want the faster program. If you have a large software base where hundreds of developers sift through thousands of lines of code, you might prefer the version that’s easier to understand. Then there’s our third criteria: flexibility. What if we want to print out numbers up to 500? What if we want a third divisor–a “bang”, or a “zazz”, that replaces every number divisible by 7? In the non-existent world of perfect software, your program should easily handle these changes, perhaps even with the modification of a single line of code. In our case, we’d need to start playing with data structures like lists and dictionaries, which will make our code more complex. At the end of the day, there’s no single solution to FizzBuzz. Figuring out different ways to solve a problem is part of the joy of programming. If you feel overwhelmed, just remember the golden rule: get your code done, get it working, and worry about the rest later. Above all, have fun! b


JEFFREY LIN, UNSPLASH

Secret Languages Codes

4

BY SIMON BATT

Getting Past the Man in the Middle If you’ve tried some of the codes we explored in past issues, you’ll know how good they are at keeping messages secret until they reach the intended recipient. As long as both you and your friend have the key that decrypts the code, your message can fall into anyone’s hands and they’ll have no idea what it says. This keeps the contents secure until it reaches the intended recipient. While making codes to share with your friends may seem old-fashioned, it’s still used to this very day. In fact, if you’ve ever used the internet, there’s a very high chance you’ve already engaged in encryption; you just never performed it yourself! When you send and receive data from the internet, you do so using ‘packets’. These are little bundles of data that carry things to and from your computer. From giving a website your login information to getting streamed video data from YouTube, you’re constantly sending and receiving data via these packets when you use the internet. Just like sending a message to someone else in the real world, sending packets over the internet has its privacy issues. There’s a kind of attack called the ‘man in the middle’ attack, where a nasty hacker reads packets going over a network and extracts data from them. If someone is sending their username and password over an unencrypted packet, the hacker will have all of their login details without the victim even realizing! Thankfully, we have ways to stop ‘man in the middle’ attacks. One way is to encrypt the packets being sent between two computers. You don’t need to lift a finger; likely all the sites you’ve visited before have done this for you! Have you ever noticed that some websites you visit start with “http://” and others start with “https://”? The ‘http’ stands for HyperText Transfer Protocol, and the additional ‘s’ stands for Secure. Regular http is used when the site isn’t handling important information, but the moment sensitive data comes into play (like your login details), the connection becomes secure to protect your data. If you’ve paid close attention, you’ll notice that ‘https’ appears when you visit a site where you have to enter sensitive information. Unlike regular http, https uses an encrypted connection. This works very similarly to the messages you send your friends! Your computer and the receiving computer agree on a secret encryption code to work under. Then, they start sending each other packets using this encryption. If a hacker manages to ‘catch’ a packet, all they’ll see is encrypted data, much like how anyone who reads your secret messages would see only gibberish. People who want to secure their sites with https must first buy a special certificate called an SSL (secure sockets layer) certificate. This certificate verifies that the website is who they claim to be, and isn’t trying to trick people. If you want to avoid ‘man in the middle’ attacks, it’s a good idea to only enter your personal details on sites that use https. It’s very easy to check; just take a look at your address bar for ‘https’ at the start, and a little padlock icon to the left. Likewise, if something went wrong with the HTTPS service (for example, their certificate is out of date), the browser will display an error saying the site isn’t as secure as it’s claiming, and that your details are at risk. b


The Paperclip Maximizer We all know paperclips are thin metal wire bent into shapes to make it easy to hold together two or more sheets of paper. But are they dangerous? Could a machine that makes paperclips hurt people? The effort to make computers as intelligent as humans has led to a thought experiment called the Paperclip Maximizer. Imagine a computer designed to do what humans do to make paperclips. It would buy metal to turn into paperclips, create paperclip designs, buy machines to make paperclips, hire people, and so on. The computer would be given one task: create paperclips. Now imagine the computer also has the ability to learn from mistakes and to figure out possible future scenarios, all to ensure it can make paperclips. The computer would learn to do its job well. When the computer ran out of metal, for example, it might try to find other raw materials that could be turned into metal. When that no longer worked, the computer might look in our solar system, then beyond. The computer would do its job but earth would be buried in mountains of paperclips. Could people stop the computer before it destroyed earth? No. The computer would think of that possibility early on, as part of figuring out how to make sure it can produce paperclips. It would identify all obstacles, humans included, and plan how to prevent them. Obviously, creating artificial intelligence to complete a task is not enough. Machines also must have values shared by humans. The paperclip-making computer values creating paperclips, even if it means using up every last bit of metal on earth. However, the result of using all the metal on earth destroys what humans value most, their need to live, to preserve human life. The Paperclip Maximizer is a way to debate the limits of artificial intelligence. Creating a human-like intelligence in a computer might be the last thing humans do. b PLUSH DESIGN STUDIO, UNSPLASH

5

Concepts

BY TIM SLAVIN


Concepts

6

File Systems

BY CLARISSA LITTLER

BOB SMITH, FREEIMAGES.COM

Operating systems are complex beasts, full of many moving parts that allow the user to interact with the hardware. In this article, we'll be talking about one of the more important and more easily overlooked services every OS has to provide: the file system. By file system, I don't mean things like the explorers in OSX or Windows that let you see visually where all your files and directories are. I mean the code beneath all of that that enables the concept of "file" to even make sense to the computer. "Files" aren't actually something a hard drive, a USB drive, or an SD card naturally understand. Anything beyond "this value is stored in this tiny box for data" is implemented by the file system and was coded as a part of the OS. OSX, Windows, and Linux all have their own file systems. Linux actually has a bunch of file systems you can choose from. What's the first big complication for a file system? Defining what a "file" is in the first place, then keeping track of where its data goes! A good file system makes a file look like it's just one long chunk of continuous data. They're frequently not, though! Imagine if you have an 8GB file, like a movie, that you want to download and you have a bunch of tiny spaces free on the drive that are each a few hundred megabytes in size. It'd be silly to not write the file to the drive just because you can't find one big space. Instead you'd split the file into a bunch of pieces and put them in all the open spaces. That's what every modern file system does! What might not be obvious reading this is why there'd be weird gaps in the drive to begin with. Well, that's a consequence of files needing to change! Imagine you're recording a video to put on your YouTube channel. Raw video data tends to be pretty big! Once you hit record, your computer writes the data to its drive in some available space. It'll fill up that gap in the drive while it can and then keep going in other available spaces. Let's say you record a whopping 20GB of high-definition video. When you edit it later, you'll be cutting a lot out and deleting that data. Now you've created new gaps where other data will get put later! The other big thing that a file system needs to do is handle the logical hierarchy of your files: directories, folders, sub-directories. The actual storage doesn't reflect the hierarchy. Files in the same directory aren't all near each other in storage. You wouldn't want them to be! If they were, it'd be so slow to move files around between directories. Have you ever noticed that moving files between directories happens really fast but copying is slow? This is why! The file system doesn't "move" data when you "move" files, it just changes where they live in the hierarchy. So that's a little taste of what goes into file systems and what they actually do. I always think it’s cool when there’s all sorts of complex code that goes into making something look so simple. b Check out the link on the back cover of this issue for more info!


For this issue's highlighted language, we're going really old school. Let's talk about an early workhorse language used to program hardware and write operating systems for over 40 years: C! All major operating systems today have a core of millions of lines of C code. "But what if I don't want to write an operating system?" you might ask. But if you want to program an Arduino or code up something for embedded hardware, you're going to want to use C. Now that I've hyped it, let's talk about exactly what C is and why it's still unique. But first, let's talk about runtime systems for programming languages. When you write code in Scratch, Python, Ruby, or most other languages you never have to think about how the data you use gets made. You can create a list or an array and just add elements to it as you need. When you're done using those data structures you can just forget about them and they'll be taken care of, erased by the garbage collector at runtime. If you're wondering what a garbage collector is, you can check out an older article here: https:// www.kidscodecs.com/garbagecollection/. Where does this garbage collector code live? It's running when your program runs, but it's not a part of the operating system because it's different for each programming language. Instead, it

lives in the runtime system. The runtime system for a language does a lot more than just garbage collection. Haskell's runtime handles the lazy evaluation we talked about in a previous issue. JavaScript runs the complex event handling system JavaScript uses. Ruby handles the creation of all its lightweight threads. In other words, the runtime system for most languages mediates between the operating system and the program as it runs.

C

What does this have to do with C, though? Well, C doesn't need a runtimeâ&#x20AC;&#x201D;at least not in the same sense as other languages! C has been designed so that it doesn't need this mediation, which means that it doesn't need an operating system. That makes sense! C is for writing operating systems! All that being said, what does C look like? Well here's what a for-loop looks like int i; int result = 0; for(i=0;i<10;i++){ result += i; } I'm betting this looks kinda familiar if you've ever programmed in something like JavaScript, Java, C++, or many other programming languages. A massive number of languages over the last 40 years have taken cues from C's syntax. The nice thing about this history is that C is pretty easy to pick up, for the most part. The only part that I think is still unusual is programming with pointers in C. Pointers are data types that hold the memory addresses of other data. Thereâ&#x20AC;&#x2122;s a brief overview of pointers in the online version of this article! To learn more about programming C, thereâ&#x20AC;&#x2122;s still no better place to start than Dennis Ritchie's and Brian Kernighan's book on C: The C Programming Language. It's a book so famous it has its own wikipedia page: https:// en.wikipedia.org/wiki/The_C_ Programming_Language. So that's my pitch for why C is an important language to learn. Happy hacking! b

Languages

7

BY CLARISSA LITTLER


Projects

8

s e l g n a i r T n o h Pyt

BY PATRICIA FOSTER

Triangle Time

There’s something oddly satisfying about printing out cool patterns in the console. Today, let’s tackle triangles made of stars, Python-style!

How do we expand our line of stars into a triangle? Well, you could try something like this:

Setup

Open up a browser and navigate to www.repl.it/languages/python3

Figcaption:

It’s a bit annoying to type in the full address, but if you go straight to the website’s main page (www.repl.it) they’ll ask you to create an account or log in with Google or Facebook. This is also an option, especially if you want to save your work. On your left you’ll see your editor, where you write your code. On your right is your console, which displays the result of the code. To display a single star, add the following line to the editor and then hit the “Run” button (the green rectangle with a tiny triangle) at the top of the screen.

But that code’s long, clunky, and it has lots of potential for typos. A better solution is to use a coding structure called a while loop. The purpose of a loop is to repeat the same action over and over, saving programmers time and energy. All the code inside the while loop is run until the loop’s condition becomes false, at which point we exit the loop. We also define some variables that make the code easy to tweak. length = 1 MAX_LENGTH = 10 while length <= MAX_LENGTH: print ("*" * length) length += 1 Copy the code into your editor and hit the run button to try it out.

print("*") Make sure you have an opening and closing bracket, and that your asterisk is surrounded by quotation marks. To print a line of ten stars, just add ‘* 10’ inside the round brackets : print("*" * 10)

our triangle. Let’s start at 10. The condition on line 4 says that in order for the loop to run, the value of length must be smaller or equal to MAX_LENGTH. Length starts at 1, and MAX_LENGTH is 10, so we’re off to a good start. We run the loop, print some stars, and increase the value of length by 1, making it 2. On the second run of the loop, length (2) is still smaller than MAX_ LENGTH (10). On and on we go, replaying lines 5&6, increasing ‘length’ each time, until the variable has a value of 11 and the condition of the loop is no longer true.

Breaking Down the Code

Our “length” variable counts the number of stars printed in a single line. “MAX_LENGTH”, as the name hints, is the maximum length we want in

Line 5 is the code that displays our triangle on screen. As you can see, we multiply the asterisk with a variable instead of a fixed number. Because the value of “length” is changing every time we run the loop, the number of stars printed onscreen increases at every round. If you want to adjust the size of your triangle, you can do it by changing MAX_HEIGHT to 5, 50, even 1000! Since you’re using a loop, the


Inverse Triangles

What if you wanted to print an inverse triangle, like this?

See if you can solve it by yourself! The trick is to start ‘length’ at 10, and define a minimum length instead of a maximum length. What other pieces of the code do you need to change in order to make this work? Solution: length = 5 MIN_LENGTH = 1 while length >= MIN_LENGTH: print ("*" * length) length -= 1

b Look for more info on this topic by checking out the link for this story on the back cover of this issue.

BY CARRIE NORWOOD

Thanks, USO!

On September 30, 2018, USO of Illinois and BMO Harris Bank, a Military Youth Programs sponsor, hosted an afternoon of coding fun at the futuristic makerspace Code Play Learn in Oak Park, Illinois. The age-appropriate sessions opened the world of coding to participants through the creation of Minecraft mods and programming Raspberry Pi systems. Military kids in grades 1-8 learned about the JAVA programming language and built their own Minecraft mods that could be uploaded into the popular video game, Minecraft. In post-event feedback, one of the young participants shared how they loved learning about coding, and how having practical experience was key to their future success. In addition to the fun coding session, BMO Harris Bank gave each participant a year subscription to beanz Magazine! The program’s high schoolers explored how software and hardware can be combined and configured in infinite combinations to make and create. As part of the program, each participant received a Raspberry Pi from BMO Harris Bank and learned how to use Python to control hardware, LED lights, and cameras. The son of an Air Force reservist was already planning his next coding project and shared, “I hope to mess around and tinker with it and take it to school.” For the participants’ parents, the highlight of the day was seeing their children’s eyes opened by the world of coding. “Thank you so much for the wonderful program and allowing my child to discover new passions,” one parent said. “She can’t wait to do more with the Raspberry Pi!” Juanita Hardin, Air Force Veteran and Chair of BMO Harris Bank’s Veterans Advisory Council says, “At BMO, we are committed to supporting military families. We understand that, while the individual is recruited, the entire family serves. Today’s STEM event is a natural evolution in BMO’s advocacy of financial literacy that grooms tomorrow’s innovators.” USO strengthens America’s military service members by keeping them connected to family, home and country, throughout their service to the nation. One of the ways USO of Illinois supports military families is through USO Military Family Programs, which are designed to lift the spirits and provide a sense of community support while members enjoy unique recreational and educational opportunities. b

9

Events

program automatically implements the changes.


Notebook

10

元宵節 BY JENNIFER NEWELL

Lunar New Year

For many countries throughout Asia, late January through early March is a time of celebration centered around the Lunar New Year. Although in western countries we sometimes refer to this period as Chinese New Year, it is recognized in many countries from Vietnam to Korea, making it one of the most celebrated holidays in the world. Perhaps less known is that, on the fifteenth day of the new year, a lantern celebration marks the end of two weeks of festivities. Children often carry small lanterns through the streets to light up winter darkness and welcome spring. In parts of Taiwan and China, thousands of people send sky lanterns adorned with wishes for the new year up into the sky. And across Asia, high tech lanterns of all

(Lantern Festival)

shapes and sizes light up cities and are often powered by batteries and LEDs, not fire. Why Lanterns?

Many stories explain possible origins of this 2000 year old tradition. One tells of a Chinese emperor who strongly advocated Buddhism and noticed that Buddhist monks would light lanterns in their temples on the fifteenth day of the lunar month. Another tells of the Jade emperor planning to storm a village on this day. To save themselves, the villagers hung red lanterns, set up bonfires, and lit firecrackers. This gave the appearance that the village was already burning and the emperor did not attack. Lanterns and Code

Many cities across the United States have their own lantern

MARUFISH, FLICKR

celebrations. And for those of us who love DIY projects and want to add a bit of code to the celebration, we can make our own lanterns! Lila Finch, of the Laboratory for Playful Computation at the University of Colorado in Boulder, developed a beautiful fun lantern project that mixes her interest in science, coding, and art. The lanterns can be made by middle school students on up and younger children, as well, with adult assistance. Her project uses techniques developed by the nebuta lantern makers in Amori, Japan and adapted for both science, coding, and art projects across the world. These lanterns are made with galvanized steel wire, found at most hardware stores, held together by parcel post twine or similar strings dipped in glue, and covered with standard printer paper. Once assembled, they are painted with cold water dye or other thin paint and melted paraffin wax to allow for amazing colors and intensities of light to shine through. And for the coding? Lila uses strings of Neopixel LEDs connected to a micro:bit to light her amazing lanterns. Previous issues of beanz refer to many fun micro:bit projects, with instructions on how to program these kid-friendly microcontrollers. With a single click, the Neopixel library can be imported into the micro:bit programming environment, similar to Scratch and Blockly, allowing lantern designers and programmers to easily control the color of the LEDs. A few blocks of code make them blink, light up one-by-one, and fade in and out, among other cool effects. Interested in giving this project a try? Step-by-step instructions are here: https://www.instructables. com/id/Paper-and-Wire-Lantern/. With the lantern festival coming up on February 19, 2019, Lila’s lanterns make for a timely project that welcomes the spring with elements of culture, art, and code! b


tidbitz Say My Name A new headset called CARA helps blind people navigate new spaces by having objects say what they are, for example, a door on the right or a chair in front of them. The computer in the headset recognizes objects then says their names. b

11

When In Rome...

Ever wanted to fly over ancient Rome to see what people saw and where they lived nearly 2000 years ago? A two-hour virtual reality tour lets you fly around animations of the ancient buildings and statues. There also are a number of videos with amazing recreations. b

https://www.engadget. com/2018/11/29/arheadset-tech-helps-blindnavigate/

https://www.romereborn.org/

CALTECH

What in the World??

https://www.smithsonianmag. com/smart-news/vrexperience-restores-7000roman-buildings-monumentstheir-former-glory-180970901/

The NASA channel on YouTube includes an updated high definition video feed from cameras attached to the International Space Station. Make the video full screen on your computer and watch as the earth rolls past with clouds, oceans and lakes, and land. b https://www.youtube.com/watch?v=pw4WZObNqss

IMAGE FROM ROMEREBORN.ORG IMAGE FROM NASA CHANNEL ON YOUTUBE


BY JENNIFER NEWELL

What Cell Tower? Today approximately 63% of people in the world own cell phones. For many they are the primary device used to call and message others. But those of us 30 years of age or older recall a time when all phones were landlines connected to the walls of our homes, and messaging did not even exist. When and how did this transformation in communication take place, and how do mobile devices send and receive messages wirelessly? The first call from a mobile phone was made in 1973, traveling through low-powered towers. Nearly 20 years later, in 1992, the first text message (merry christmas) was sent through a much more developed cellular infrastructure. As cell phone technology improved and both messaging and calling from cellular phones has become increasingly popular, cell phone towers have sprung up across the globe. Without a cell tower to convert the radio waves sent by the phone into electromagnetic waves, our messages and calls would never be received. But these towers can be something of an eyesore. Most cell towers stand between 50-300 feet tall. In rural areas, they are often constructed on hills or mountains as increased height leads to increased range. How does one hide such a conspicuous structure? In urban and suburban areas, cell towers are sometimes built within a flagpole or the bell tower of a church. But, where such structures are not already available, or the community opposes the addition of a cell tower within them, towers are sometimes designed to blend in with nature. Usually this is in the form of a tall tree or cactus. Though these cell tower trees now have more natural designs than the originals built in the early 1990s, they still usually stand out as bizarre, artificial, trees. Many argue that they are no better than the cell towers themselves! The way of the future

No one can be sure what the future of messaging and mobile calling holds. However we do know that the fifth generation (5G) of wireless service is scheduled to roll out in 2019 and 2020. 5G technology will bring faster service traveling through shorter wavelengths, and that service requires cell phone towers be closer to users than the towers of 4G typically are. This means we will likely see more smaller “towers” springing up. In fact, they will not be towers at all, but rather antennae installed on existing utility poles. Sometimes these antennae will be accompanied by “boxes” on the ground that can be disguised as mailboxes. All this allows for higher frequency, faster waves that bring us faster service. Science Fiction? FRANCISCO ANZOLA, FLICKR

Tech in Real Life

12

After 5G wireless service rolls out, we may start to see even more dramatic changes to messaging. Currently the medical industry is developing wireless devices that can be embedded in our bodies to help diagnose and cure illnesses. In theory those same devices that send and receive messages between patients and doctors could transmit messages of the sort that we send through text and internet-based messaging apps. And if that were to happen, perhaps the cell towers being built throughout our communities would become yet another relic of obsolete technology. b


13

Mymo

BY ERIN WINICK

Projects

I Love This!

Valentine’s Day gift shopping is in full swing. It can be hard to find the perfect card or gift. Why not make it? 3D printing is here to help! There are some amazing resources online for making the perfect custom gift for Valentine's Day, and you don’t even need to own a printer! Just make sure to consult with a grown-up before making any purchases online. Check out these 5 options below. 1. Mymo: http://www.mymo.is/

Looking for an extra special gift for your parents? Get them an awesome custom necklace or keychain. All you do is enter some letters that are important to them, and Mymo will generate a view of your custom piece. You can order it directly from them in 14K gold, sterling silver or stainless steel! They use metal 3D printing to make the pieces. Prices start at $75 2. Cookie Caster: http://www.cookiecaster.com/

This is the perfect gift for baking fanatics! Cookie Caster lets you create cookie cutters of any shape you like. You have the option of freehand drawing your cookie cutter or importing an image and tracing it. Your imagination is the limit. Then, if you have your own 3D printer, you can just download the file and print or you can upload the file to a site like Shapeways that will print it for you. Maybe add a special touch by giving a batch of cookies you made along with the new cookie cutter!

Cookie Caster

Thingiverse

3. Variable Word Sculpture: http://www.thingiverse.com/thing:1038261

Create a sculpture from a short message or meaningful word to give to your friends. You could write out BFF, or a silly inside joke! This generator, created by Roebi on Thingiverse (a website for hosting 3D files for free download), lets you create the file with the word of your choice. You then download it for printing yourself or through a printing service. It’s an easy, fun, and thoughtful gift! 4. Mineways: Minecraft Model Creator: http://www.realtimerendering. com/erich/minecraft/public/mineways/

For the gamer in your life, turn their Minecraft masterpieces into 3D models! Simply select an area of the Minecraft world and the program transforms this area in to a 3D printable file. You can create something yourself in Minecraft for your valentine. Then either print it yourself or go through an external 3D printing service like Shapeways or Sculpteo.

Mineways

5. Ciphering: http://ciphering.me/

Turn meaningful numbers and dates into a custom ring with Ciphering. They describe themselves as creators of personalized generative jewelry. They let you design your custom ring in everything from sterling silver to platinum, and in the thickness and size you choose. They create a 3D wax form, which is then filled with the metal of your choice. Whether you are putting your birth date in a ring for your parents, or just encoding their lucky number, this makes a Valentine’s gift to remember. There are lots more places just like these. Go exploring this Valentine's Day and don’t settle for just any old gift off the shelf. Let technology help you create the perfect gift! b

Ciphering


In the Middle: A Deeper Dive Into Everyday Stuff

14

… s r e t u p m Co ? s r a C in BY TIM SLAVIN

You might wonder, why are there computers in cars? Because computers are more reliable and use fewer wires than their older, mechanical equivalents. For twenty years, since 1996, cars have used computers to control different parts of the car. The computers, however, are not desktop, laptop, tablet, or phone computers like we’re used to. They’re micro computers more like a Raspberry Pi, a set of chips with software loaded into memory. Each computer talks to other computers connected together into a network. Several network types are used in cars based on what they control. For example, important controls like the dashboard, navigation, and engine use a Computer Area Network (CAN) with messages passed back and forth. Each computer in a CAN is able to process messages. Controls like turn signals don’t require complicated, robust networks like a CAN. They use a Local Interconnect Network (LIN), which has a master computer connected to subordinate computers, called slaves. There are other networks in cars, for example, a network to manage safety devices and newer types like FlexRay. Which computers and networks exist in a car depends on the auto manufacturer and age of the car. Today there are anywhere from 18 to 80 computers found in cars! They are connected with cables. But in the future, most likely wireless networks will be used to connect them. This diagram shows some of the key controls and networks found in automobiles. b

C9

FlexRay (FR) FlexRay is designed to be faster and more flexible than a CAN. FR1 Brakes FR2 Star Coupler (combines signals entering from multiple input ports and divides them equally among output ports)

L4 A1

C5

L9

C1 C2

L8


15 DOLLAR PHOTO CLUB

Automotive Safety Restraints Bus (ASRB) The ASRB manages the safety features in a car. A1 Pedestrian Protection Unit A2 Airbags A3 Seatbelt Pretension

A3

FR2

C3 C6

A2 L2

L5

L7

C7

L10

L1 C4

C8

L6 L3

Local Interconnect Network (LIN) The LIN is used as a CAN alternative where lightweight connections are needed.

FR1

L1 Power Windows L2 Windshield Wipers L3 Doors L4 Rain Sensor L5 Seat L6 Door Mirror L7 Turn Signals L8 Headlights L9 Air Conditioner L10 Rear Lights

Computer Area Network (CAN) CAN allows microcomputers to talk with each other without a host computer. C1 Engine C2 Accelerator C3 Body Computer C4 Dashboard C5 Navigation/Audio Systems C6 Steer by Wire (SbW) Electronic Control Units (ECU) C7 Seatbelts C8 Suspension C9 Millimeter Wave Radar JOSE CAMÃ&#x2022;ES SILVA, FLICKR


Scratch

16

BY CLARISSA LITTLER

For info on Scratch go to https://scratch.mit.edu

Telling Stories in Scratch Sometimes you want to make something in Scratch that isn't a game per se, but more of an interactive story. In this article, we'll be covering some of the tricks and techniques that make it easy to tell a story. We'll start with the easiest way to make a story in Scratch: hard code a bunch of character actions with explicit timings. Let's choose two characters for our small work of theater.

They each have a small script telling them what to do. The dinosaur's code looks like:

recalculate each of the waits. Suggested experiment: try making a story with more than three back and forth bits of dialogue between two characters. Then add an extra line into the middle of the dialogue. What do you have to change to keep the rest working? Start by finishing our story of a dragon meeting its mom again. Let's try a different way of telling the story that's easier once you want a lot of dialogue: using messages to synchronize the actions of our characters. Instead of using a wait block to cause a character to wait to do the next thing, we'll send messages back and forth between the characters. Here's the new code of the dinosaur:

I don't have to change anything else in order to keep all the actions synchronized. Even if this trick doesn't seem like a big deal for something small, it's going to help out a lot as you develop large stories that involve multiple characters. So let's add a little something more: I'm going to have a third character enter the scene at the end. I made a new dinosaur sprite and then went ahead and added some new code to it:

and the code for the dragon: and the dragon's looks like:

Now we can continue telling a story this way, syncing up the thinking, saying, and motion with explicit wait commands. This works fine if there are only a few bits of dialogue in your story, but what if you want to add to or change the story? You're going to have to

This might seem like more work initially than using wait blocks, but it will be easier to change dialogue. If we wanted to add another line of dialogue in the middle of one of the exchanges, we can just add it directly and not worry about fixing anything else to synchronize. If I change the dragon's dialogue to:

My gosh, what a plot twist!! Where is this story going? Feel free to start from this story, which is linked at the end of the article, to make something new! One last thing: you can also use the when backdrop switches to and switch backdrop to blocks, found in Events and Looks, respectively, to synchronize all the characters across scene changes rather than just between back and forth parts of dialogue. Our story so far: https://scratch.mit.edu/ projects/256976067/. b


For info on Minecraft go to https://minecraft.net

Telling Stories in Minecraft Minecraft is a great game to play with friends in a unique sandbox, where players create their own fun. While building bases and creating inventions are fun, the stories that the game provides are entirely dependent on the players playing it. That escape from a Creeper, the long mining excursion that ended in a cave network packed with diamonds; these are stories the players make for themselves. If you’ve always wondered what it would be like if you played Minecraft with an overarching story written by someone, you’re in luck! There are two ways you can experience Minecraft with a little bit of narrative: Minecraft Story Mode, and Minecraft Maps. Minecraft Story Mode

Minecraft Story Mode isn’t playable via the base Minecraft game. It’s actually an entirely different game, created by Telltale Games. Telltale created games that tie in with other popular stories, such as The Walking Dead and Sam & Max. Due to Minecraft’s success, Telltale created Minecraft Story Mode, a narrative game based in the Minecraft world. This doesn’t play like regular Minecraft, either! In this game, you play as Jesse, a newcomer to the world of Minecraft. In the game, you have to make friends and help save the world from an encroaching evil. Unlike Minecraft, you don’t always have direct control over Jesse. Sometimes you can walk around the world as Jesse, but most of the time, you’ll be watching a story unfold as the game directs the characters. It’s not just a movie. The game

will often give you choices on what to do at specific points of the story. You have to consider each choice carefully, however, as each one influences the story in specific ways. If you do something your friend likes, they’ll come to appreciate you more. If you do things they disagree with, they’ll let you know! The Minecraft Story Mode game can be found on PC, Mobile, PS3/4, Xbox 360/One, and the WiiU/ Switch. It’s even getting a Netflix adaptation soon, so keep an eye out if you’re a fan of the site! Minecraft Maps

This is another narrative game in the Minecraft world. These are worlds that people create with an overarching story to them, usually made with the default tools available within the game. Players can download maps and play through the story and worlds the creators have made. The real strength to story maps is their variety. People can create

a world that tells any story, from a science fiction world to a fantasy setting to a challenge map where the player completes specific tasks in order to progress. They’re a lot easier to make than mods, too, so you’ll find a lot more people making them. Have a look and pick out the ones that interest you! If you need a little help installing the maps, don’t worry; check the back cover of this issue for a link to the online article, where you'll find links to a handy guide on how to get your maps installed and ready to play. It’s different for each system, so be sure to find the one that matches your computer or mobile device. Sometimes it can be fun to explore a pre-written story set in the Minecraft world. StoryMode is one of the better examples of this, but you can also download player maps without having to get anything more past the base game. Explore both of these options and enjoy the stories! b

What's the story?

17

Minecraft

BY SIMON BATT


BY PATRICIA FOSTER

Concepts

18

Requests &

Visiting a website is as natural as walking out the door and heading over to the park. You type in a URL or search a few keywords on Google, and within half a second you’re bombarded by images, text, and interactive content. It’s so natural that we don’t always stop to think about the complex mechanisms that allow us to access Google, Facebook, or Netflix. What Is a Website?

A website is a collection of code files. One file determines the page’s layout; another file decides what happens when a user clicks a button or uses the search bar. HTML, CSS, and JavaScript code are combined to make the website work as intended. Combined with these ‘.html’ and ‘.js’ files are images and other multimedia. In essence, each website is its own mini-program. The code is stored on the website’s server. A server is a computer, much like the one you use at home, just more efficient and specialized. Thousands of servers

are kept in data centers and, often, companies making a website rent out a particular server (or even share one!) and access it remotely. Website servers don’t need to be user-friendly. They’re not made to run complicated, visual programs like Skype or Photoshop. Instead the server’s only job is to listen and respond to client requests. When you visit a website, you make a request to access the server’s code, and the files are sent over the network. Your browser is the program that actually runs the code, which is why a website might look slightly different if you’re using Chrome vs Safari. Attached to every server response is a status code that indicates whether or not the client’s request was successful. You might be familiar with a couple of them: 200—Ok 404—Not Found 408—Request Timeout 500—Internal Server Error Want to see requests and responses in action? Let’s use your browser’s Inspector feature!

1. Open your browser and go to www.kidscodecs.com. 2. With Chrome, right-click anywhere on the webpage and select ‘Inspect’. With Firefox, hit ‘Ctrl+Shift+I’ if you’re using Windows and ‘Cmd+Shift+I’ if you’re using a Mac. Your Inspector might appear in the right-hand side or at the bottom of the page. A 3. Click on the ‘Network’ tab in the top bar of the Inspector. B 4. Refresh your webpage, and watch as the responses flow in! C As you can see, your browser makes a separate request for each file. If you refresh again, you might see some of the status codes change from 200 (Ok) to 304 (Not Modified). This means that instead of being sent over the network, these files are being retrieved from your browser’s cache. Meet and Greet

When you meet someone for the first time, you might say “Hi, I’m Olivia. It’s nice to meet you.” The other person responds with


19

Responses

RAWIXEL, UNSPLASH

their name, and then you shake hands, or you wave and grin at each other. The exact words and gestures vary, but the overall process stays the same: Start with a greeting State your name The other person returns a greeting The other person states their name End with a bonding gesture You are now friends! This is a simple protocol for introducing yourself. A protocol is a series of well-defined steps that two computers (or people) follow in order to perform an action, like connecting to a website. It would be weird if you say “Hi, my name is Josh” and the person responds with “I like cornflakes”. Or worse, what if the other person doesn’t respond at all and simply stares at you? What do you say? Sticking to a protocol ensures

that communication goes as planned. Just as we have different social protocols—introducing yourself at a party versus ordering food at a restaurant—there are different network protocols. The most famous is the HyperText Transfer Protocol, or HTTP, which we use to access content over the web. HTTPS is a variation of HTTP that involves encryption to make it more secure. You may also have heard of FTP (File Transfer Protocol), TCP (Transmission Control Protocol) or UDP (User Datagram Protocol). The first part of a URL shows you which protocol is being used. On the surface, browsing the web may seem sleek and simple, but dip below the waters and you’ll see a world teeming with complexity and mystery! Networking is an increasingly important concept in today’s world of smartphones and social media. Websites, servers, and network

protocols are only a small piece of the puzzle. There’s so much more out there to discover! b

A

B

C


Best Practices

20

BY SIMON BATT

Multiplayer Games If you’re an avid gamer, there’s a good chance you’ve played an online game before. These games connect you with players all around the world in one game, so you can play with (or against!) one another. Have you ever wondered how they work? For multiplayer games to work, there needs to be a ‘central hub’ which every player’s game reports to and receives reports from. Sometimes a game may select a specific player to be the host of the game; this is called a ‘peer-to-peer’ service. Most of the time, however, the developers of the game provide a central server which all players connect to. The server is where all the action takes place. You can imagine the game being played inside the server itself, if it helps! When you take an action in the game, it sends a message to the server saying what you did, and the server tells your game what happens next. As such, the main game isn’t happening on your PC; it’s happening on the server, and your game is simply a window through which you can watch and interact with the game. Let’s say you're playing an online fantasy game and you cast a fireball at a zombie. Your game tells the server ‘my player has decided to throw a fireball at a zombie’. The server listens to this, plays it out in the game that it’s running, then sends back a message saying ‘you managed to defeat the zombie’. Your game hears this and displays the zombie’s defeat on your side. Of course, the amount of communication between your game and the server varies

ETHAN HOOVER, UNSPLASH


21 depending on the kind of game being played. If you’re playing chess with someone online, then the game lets the server know where you moved your piece, and the server lets you know where your opponent moved theirs. When you look at Fortnite, however, there’s a lot more data to tell everyone; custom clothes and animations, the weapon each player is holding, where they’re looking, what they’ve built, and whether or not they’re on the move, to name but a few. This takes a lot of work to provide a smooth game experience! As you can see, there’s a lot of back-and-forth between your game and the server. Your game is telling the server what you’re doing, and the server is telling your game what’s happening in the world. This is all well and good, but problems start to arise when the communications get spotty. If the server is a long way away, it takes longer for the messages to reach the other side, which causes the game to feel ‘laggy’. If you see a server with a ‘ping’ number, this number is the amount of milliseconds it takes to talk to the server. The lower the number, the less lag there is! Servers also have to be vigilant to uphold the game’s rules. If the server simply accepted any message from a player, then a mischievous hacker can tell the server ridiculous things like ‘my character is always full health’, or ‘my character defeats everyone on the server’. To stop this, servers need to match up what the players are saying with the game’s rules. If they spot someone trying to cheat, they can disconnect them to stop them from ruining others' fun! b


SketchUp

22

BY BONNIE ROSKES

It's All Blurry! SketchUp is a free and fun program for 3D modeling. There is a downloadable version called SketchUp Make, at https://www. sketchup.com/download/all. But there is also a web-based version called my.sketchup at www. my.sketchup.com. For this project, look at the crisp, sharp squares in the middle of a field of blurry circles. A Even though this is a 2D model, it looks as if it’s 3D—the squares seem to be floating. After a while, the circles look to be moving or shaking, while the squares stand stock-still. To make this in SketchUp, go to the SketchUp page and launch your modeling session. You'll see a man (Josh) standing on the ground with axis lines around him. The red and green axes are on the ground, blue is for the vertical direction. Click the Eraser icon or press the E shortcut key. Click on any edge of Josh to erase him. Since the model will be drawn on the “ground,” we need to switch to a bird’s eye view—looking down on the ground from above. On the right side of the window, click the Views icon. B Then click the icon that looks like the top of a house. C You should now be looking straight down onto the red-green plane (a.k.a. the ground). Start by creating the circles. Press C for the Circle tool, and click two points to create a small circle. D The blurry effect is created by painting concentric circles with progressively darker colors. So we need to take this small circle and make several more circles from the same center. The tool for this

is Offset, which you can find by clicking the Push/Pull tool and choosing Offset from the flyout. Click anywhere on the circle, keep the mouse button pressed, and drag the mouse outward. Click when your offset circle looks like this: E For the next circle, move your mouse anywhere in the outer circle and double-click. This repeats the offset distance from the first circle. F Now we have three circles, and we want a total of 10, to be painted with 10 colors. So repeat this double-clicking seven more times, each time double-clicking on the outermost circle. If you make a mistake and get a wrong offset, use Undo (Ctrl + Z or Cmd + Z) and start over. Now we can paint all of these faces. On the right, click the Materials icon. G On the Materials window, click the Browse icon, then open the Colors collection. H Scroll to the bottom of the list of colors, where you’ll find white and black and the eight grays in between. There are 10 of these colors, which is why we made the 10 circle faces. I One by one, paint each face, starting with white on the outside and proceeding toward black in the center. J This set of circle faces will be used to make copies, so it needs to be made into a component. To do this, press Ctrl + A (PC) or Cmd + A (Mac) to select everything. Then right-click on any selected face and choose Make Component. K Give the component any name you like, and click OK.

The completed component will have a selection box around the whole thing, which means it’s now a single object, and it is selected. Leave it selected. L Press M for the Move tool, and press the Ctrl key (PC) or Option key (Mac). The Ctrl/Option key switches from move to copy. Just tap this key, don't keep it pressed. For the first copy, click anywhere to start. Then move the mouse directly to the right, and click again when the copies are spaced like this: M Instead of just one copy we want several, and just after the first copy is placed is when you can set your number of copies. Type 7x, which appears in the Distance field in the lower right corner. (Don’t click in this field, just type and the numbers appear.) Press Enter, and the single copy turns into seven, making a total of eight circles. N Select everything again, and Move should still be the active tool. Press Ctrl/Option again, and place the first copy directly above or below the selected row. O Type 7x again and press Enter, to get the complete grid of blurry circles. (They'll look blurry soon.) Some of the circles in the middle of the grid need to be replaced with the sharp squares. Press the Spacebar to activate the Select tool, and press and hold the Shift key to select multiple objects. One by one, select the 16 squares in the middle. (You can also drag a selection window to select these, but be careful not to select any extra circles.) P Right-click on any selected circle and choose Make Unique. To open one of these unique components for editing, the Select tool should still be active. Double-click on any of the unique components. The edited component appears in a dotted-line box, and everything else is faded in the background. Q

Check out the link on the back cover of this issue for more info!


Use your scroll wheel to zoom in closely on this circle. Press R for the Rectangle tool, and tap the Ctrl/ Option key to create the rectangle from its center. Click to place the center where the center of the circle is. R Move your mouse so that the rectangle will be a square, at about the same size as the largest circle. Note that whatever changes you make to this component will be made to all of the same components. S Then use the Eraser to remove all of the circles. Only the square remains. T Use Offset again to make another square just inside. Paint the square border black. U To erase the large square face in the center, activate Select and click this face to select it. V Press the Delete key to remove this face. The component editing is now finished. So to close the component, while the Select tool is active, click anywhere outside the component. Now, make the blurry circles blurry. Open any of the original circle components for editing. Activate Eraser, and while keeping the Shift key pressed, sweep your mouse over all of the circle edges. This hides the edges. W Close the component, and now all of the circles have hidden edges. But the blurry effect still canâ&#x20AC;&#x2122;t really be seen, because the background is still gray. So for the last fix, click the Styles icon on the right. X In the Styles window, click the Browse icon, and open the Default Styles collection. Y Pick anything that has painted faces, a white background, and no sky or ground color. Z And thatâ&#x20AC;&#x2122;s it! Against white, the circles now look blurry and the illusion looks much more clear. b

A

B

C 23

D

E

F

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

b

G


Electronics

24

n w O r u o Y d l d i r u a B o B t i u c r i C

BY LES POUNDER

go to ro:bit sellers c i M rg/re fo on For in microbit.o :// https

You'll Need:

• A micro:bit • 5 Crocodile clips • Buzzer • LED • Copper slug tape • 5 Bulldog clips (bare, no plastic or paint) • 2x Brass paper fasteners • Letter-sized sheet of card stock

Let's create our own computer circuit that uses the micro:bit as a power source, to process the input of our user, and to perform a corresponding output. All with common stationery items! In this project, we will learn about loops and how we can have loops running in parallel, conditional tests, how they can be used to change the flow of our code, and inputs and

outputs and how the computer will understand what to do. Hardware

Take a piece of letter-sized card and fold in half lengthways to make the firm base. Use glue to ensure that the card stays folded. Or use cardboard and skip this step. The first strip of tape for our circuit is the GND connection. Measure a length of tape to go the full length of the card plus 20mm so that we can secure the tape to the card by wrapping it over. Use a cylindrical object to smooth the tape down as it is moved along the card. We used an old AA battery for this. Using a permanent marker write “GND” on the tape. Repeat this process at the top of the card for the 3V connection.

A

For the 0 connection use another full length of copper tape just underneath our 3V strip. Make sure they don't touch! Mark this strip as 0, as it will connect to our micro:bit’s 0 GPIO pin. For our next strip, 1, position it underneath 0, but not too close! It will only be 2/3 of the length of the card to ensure that we can create a clean circuit later. Mark this strip 1. For the final strip, 2, we need this to be under 1, and be only 1/3 of the length of our card. Mark this as 2. A With all the tape applied, clip the bulldog clips to the left edge of the tape. (Later, when we connect the crocodile clips, their “teeth” will damage the tape rather quickly. Our bulldog clips give us a secure and tough connection.) B Make the first connection between 2 and GND. This will be a momentary switch, a push button. Use a brass paper fastener. Use a pen or screwdriver to carefully make

B

C


25

a hole between the two strips. Insert the paper fastener through the back of the card and split the legs of the fastener so that one is touching the GND strip and the other is touching 2. C Using more copper tape, secure the leg to GND, but leave the leg hanging over 2 so that when it is pressed it will make a momentary connection before springing back. D The next connection is between strip 1 and GND. Use an LED, a Light Emitting Diode. Our LED has two legs. The long leg, the Anode, will connect to strip 1, using a little copper tape to hold the leg down. Then add a little copper tape underneath the shorter leg (the Cathode). This shorter leg will connect to GND using another brass paper fastener inserted from the rear of the card. The legs of the paper fastener will connect the short leg of the LED to GND. Again use a little copper tape to hold it down. As an LED is a diode (a component that only allows current to flow in one direction), make sure that connection is the right “polarity” so that the flow of current is not stopped. E

D

E

Our final connection will connect the buzzer. The buzzer has two wires, a red wire connects to strip 0, and a black wire connects to GND. If needed, strip the wires for a good connection. Use a little copper tape to secure them down. F The circuit's complete, so connect the circuit to the micro:bit. Connect each of the strips to the micro:bit using crocodile clips from the micro:bit to the bulldog clips of the circuit. Connect the numbered strip to the same numbered GPIO pin (it really is a hole) on the micro:bit. With the connections made, we can now write code. Connect your micro:bit to a computer, and in a web browser visit microbit.org. Software

We'll use the MakeCode editor on the main microbit.org website. (Click on “Let’s Code” at the top of the screen.) Then click on the Javascript block editor. We will see the Make Code editor. G On the left we have a virtual micro:bit, which we can use to simulate and test our code. In the center is the palette of blocks that we use to write code. On the right

F

is the building area, where code is created using the blocks. There are two blocks already in the coding area. “On start” is used once and runs when the micro:bit is powered up. “Forever” will continually run any code within it. Add code to “On start” by clicking on “Advanced” and go to the “Pins” blocks. In there look for “...more” and click on it. Scroll down to “set pull pin P0 to up.” Drag this block and drop it inside “on start” then change “P0” to P2 as this is where our push button is connected. H But why have we done this? We have set P2 so that the pin is turned on and has power. When the brass paper fastener button is pressed, it will connect P2 to GND, causing the pin to go from HIGH (on) to LOW (off) and triggering our code to run. Making the Buzzer Sound

For our first forever loop we'll go to the “Logic” blocks and use the “if true then..else” block. I Drag this into the forever loop as so. But this comparison test is not ready. We must check one value against another. So go back into the “Logic” blocks and use the “0 = 0” block. J

G

H


26 Drag and place it over “true”. K Now replace the left 0 with a block that will read the state of our button, connected to pin 2 of the micro:bit via our copper tape circuit. Find this block in the “Pins” section, and it is called “digital read pin P0”. Place this over the left 0 of the previous block and then change the P0 to P2 using the blocks drop down menu. L We can leave the second 0 as 0. Because we'll be checking to see when the pin is turned off. (Hint: It will turn off when we press the brass paper fastener down) Now right click on the forever block and select “Duplicate” and it will copy all of our work. Move this duplicated block of code out of the way for now. Back to our original loop. Use two more blocks from “Pins”, the first will turn P0, which is connected to our buzzer, on for as long as our finger is pressing the button. But when the button is not pressed, it will turn off the buzzer. The blocks fit as so. M The first section of code has now

“Pins” section. P So now we should have three blocks of code that look like this: Q

been completed! Making the LED Flash

For the second forever loop, start with the comparison that tests if the button has been pressed. This time we would like the LED to flash four times when we press the button, so use the “repeat 4 times” block found in the “Loops” section. Drag this into the “if” part of the code. N But what do we want to happen four times? We first want the LED connected to P1 (1 on our circuit board) to turn on, and we use the “digital write pin” block found in the “Pins” section to do that. Then from “Basic” we use the “pause (ms) 100” to stop the LED turning off too quickly. Then we use another digital write block to turn the LED off, and another pause block to stop the code running too fast. O The final step in our code is to create the code that will run in the “else” condition, which means, when the button is not pressed this code will run. In this situation we just need P1 to turn off. Again we use the digital write block from the

Download the Code

The code is complete; we now need to save it. At the bottom of the screen is a disk icon and the word “Untitled.” Change this to CardboardElectronics and click on the disk to save. It will also download a copy of the code to our Downloads folder. Plug in your micro:bit to the computer and it will appear as a USB flash drive. Now using the file manager of your operating system, copy the downloaded file to the MICROBIT drive. Once the file is copied, the drive will disappear from the file manager, and the micro:bit will begin “flashing”, which means that our code will be written to the micro:bit. Once complete the micro:bit drive will reappear in the file manager. Press the brass Paper fastener button to trigger the code to run! Congratulations! You have created your first cardboard computer circuit. b

Psst! Check out the link on the back cover of this issue for more info!

K

O

P

L

I J

M

N

Q


TIC-80: Adding Screens to your Platformer We're back to working on TIC-80, the fantasy computer for making retro games. Last time, we started the basics of a platformer: making a character react to gravity, making the ground solid, and playing with the sound wave generator. This time we'll learn how to have more than one screen for our game and how to refactor the code so we can more easily add features. We used a number of global variables—x, y, vy—to represent the state of the player: their x and y coordinates and their velocity in the y direction. We then wrote a main game loop, the TIC function, that handled keyboard inputs for movement. We drew the one screen we painted with a call to map(0,0). Our code used the mget function to ask TIC what kind of tile was in a location to figure out if we were standing on the ground. This time, we’ll be moving between screens. In TIC-80 you have a map editor that shows you the full map of the game, split visually into a bunch of screen-sized chunks. We want the player to move across this big map as they move left, right, up, and down. We'll be treating the screensized segments in the map editor as individual screens in our game and we'll switch between them as the player moves. If their y-coordinate is less than 0, we'll move to the screen above. If their y-coordinate is greater than 136, we'll move to the screen below. Similarly, if the x-coordinate is less than 0, we'll move to the screen to the left and if it's greater than 240 we'll move to the screen to the right. First, we’ll add two more global variables at the top of our code. Call

them mapIndexX and mapIndexY. They keep track of which screen we're on. Initialize them both to 0 like in the following mapIndexX = 0 mapIndexY = 0 These variables are like macro x and y coordinates. The mapIndexX and mapIndexY variables are both 0 at the upper-left corner of the map, increasing to 7 and 7 for the bottomright corner of the map. Next, we write a helper function to figure out what kind of tile is currently drawn to a part of the screen, calculated from x and y coordinates and the values of the mapIndex variables. function currTile(x,y) local realX = x + 240*mapIndexX local realY = y + 136*mapIndexY return mget(realX//8,realY//8) end And we can use this currTile function to refactor out our constant tests for whether our player is touching the ground. function isGround(x,y) local t = currTile(x,y) return t == 1 or t == 2 or t == 11 or t == 12 end Change the numbers in this function to be the indices of the ground sprites you're using. Now to the main game loop to finish refactoring and make the game switch screens as the player moves. function TIC() cls(0) map(30*mapIndexX,17*mapIndexY) if btn(2) then x=x-1

if isGround(x,y) then x = x + 1 end end if btn(3) then x=x+1 if isGround(x,y) then x = x - 1 end end

27

if isGround(x,y+6) then vy = 0 else vy = vy +1 end if btn(0) and isGround(x,y+6) then vy=-8 sfx(0,"C#4",20) end y = y + vy if x > 240 then mapIndexX = mapIndexX + 1 x=0 end if x < 0 then mapIndexX = mapIndexX - 1 x=240 end if y < 0 then mapIndexY = mapIndexY - 1 y = 136 end if y > 136 then mapIndexY = mapIndexY + 1 y=0 end spr(3+t%60//30,x,y,0,1) t=t+1 end We've coded our game so that screens are discrete units—if you leave one screen you are wholly on another. There's nothing that requires us to treat screens that way, so try making the screen move incrementally when you cross the edge. There's lots more in the online version of this article. Check out the link on the back cover of this issue. b

Projects

BY CLARISSA LITTLER


Parents and Teachers

28

BY TIM McGUIGAN

The Case for Use I've taught middle school robotics for a few years, but this year my curriculum has taken a 180-degree turn. My lessons were focused on programming, precision, and competition. I began classes by showing videos of Boston Dynamics robots running through the woods, or sleek designs from Carnegie Mellon University. My students huddled into teams and competed in real world challenges—winners and losers crowned in every class. While my units were a good introduction to modern robotics, I began to notice that something wasn’t exactly working. However, after finding the work of Simone Giertz, a roboticist and inventor from Sweden, I decided to abandon this model in my 7th-grade classes. I believe there is a case to be made for imperfect or useless robots. Once confined to the labs of collegiate computer science programs, the past twenty years has seen robotics expand to secondary and primary classrooms. With the birth of classroom-friendly platforms such as Vex, LEGO Mindstorms, and Sphero, robotics has become a real and valuable part of technology education. Students in modern robotics get acquainted with everything from collecting sensor data to advanced techniques like line-following. However, the question of what my students were taking away

cognitively always lingered on my mind. How much were they really learning about problem-solving and robotics engineering? Could they build a robot to complete a given task? I realized the answers to these questions ultimately were "not a lot" and "no." The Spheros we used were largely pre-built affairs and the LEGO Mindstorm robots were more geared towards programming and precision, at least at a middle school level. About a year ago, I found Simone Giertz’s YouTube channel where she builds robots of questionable functionality. Her robots are the opposite of what I would show to my students. Whimsical, and made from found materials, they could pass for Jetsons-era visions of a glorious and automated future. Her goofy and campy inventions clearly defy the image of modern robotics as intricate and austere. In her captivating TED talk, she demos one of her first robots, a toothbrush helmet consisting of servos mounted to a powder blue motorcycle helmet. Some of her other designs are an alarm clock robot that uses rotating rubber hands to slap herself awake and a machine that slaps popcorn into her mouth with a small rubber hand. In her TED talks, she speaks about her struggles with learning robotics hardware. Working with real-world robot components like servos, motors, sensors, and gears has a high rate of failure. Aiming to build imperfect

machines reduces the feelings of stress stemming from this failure and, to use Ms. Giertz’s own words, promotes “an expression of joy and humility that gets lost in engineering.” Moreover, her designs, however imperfect, follow the engineering design process from start to finish. This is what I wanted my students to learn: how to solve a real and immediate problem using the sometimes frustrating components of robot hardware. To accomplish this task, I invested in a few Hummingbird robotics kits and a bin of assorted detritus from our local creative reuse store. The robotics kits contain a control board and a collection of robotics components like LEDs, motors, and sensors. Compared to the LEGO Mindstorm, these components feel more primitive, which is exactly what I was looking for. During classes, my students have been more focused on making decent wire connections, how voltage affects gears, and how to program threshold values. The reality of working with these components is that they tend to fail quite often. My students have had sensors mysteriously stop working and wires break. It does not always go smoothly, but in many ways that is the point. Dealing with failure and finding workarounds is an


29

less Robots important cognitive skill that will be invaluable for them in the real world. As they are strapping components to ball caps and Barbie cars, they have to keep returning to the constant cycle of ideation, testing, and revision. And on some days there is more frustration in the room than success. However, if everything goes according to plan, by the end of our unit students will get to create something truly from scratch and reconnect with the joy of engineering along the way.

b

MATT WIEBE,, FLICKR


“Technology is unlocking the innate compassion we have for our fellow human beings.” —Bill Gates Thank you for reading this issue of beanz ! Check out the links below to read stories from this issue online with links to learn more. What Is FizzBuzz? http://beanzmag.com/ fizz-buzz-coding-test

Lantern Festival http://beanzmag.com/chinesenew-year-lanterns

Requests and Responses http://beanzmag.com/ requests-and-responses

Getting Past the Man in the Middle http://beanzmag.com/ man-in-middle-codes

tidbitz http://beanzmag.com/ february-2019-news-wire

Multiplayer Games http://beanzmag.com/ how-multiplayer-games-work

What Cell Tower? http://beanzmag.com/ cell-towers

It's All Blurry! http://beanzmag.com/ sketchup-blurry-circles

I Love This! http://beanzmag.com/ 3d-valentine-projects

Build Your Own Circuit Board http://beanzmag.com/ create-cardboard-circuits

The Paperclip Maximizer http://beanzmag.com/ paperclip-maximizer File Systems http://beanzmag.com/ file-systems C http://beanzmag.com/ c-language Python Triangles http://beanzmag.com/ python-triangle-generator Thanks, USO! http://beanzmag.com/ uso-chicago-event

Computers...in Cars? http://beanzmag.com/ automobile-computers Telling Stories in Scratch http://beanzmag.com/ tell-stories-scratch Telling Stories in Minecraft http://beanzmag.com/tellstories-minecraft

TIC-80: Adding Screens to Your Platformer http://beanzmag.com/tic80add-screens The Case for Useless Robots http://beanzmag.com/ useless-robots

http://beanzmag.com/subscribe

ribe! Subsc

Profile for beanz Magazine

beanz Magazine February 2019  

Find out how multiplayer games work, as well as computers in cars, telling stories in Minecraft and Scratch, creating games with TIC-80, bui...

beanz Magazine February 2019  

Find out how multiplayer games work, as well as computers in cars, telling stories in Minecraft and Scratch, creating games with TIC-80, bui...

Profile for beanzmag