beanz Magazine

Cardboard Circuits

IQRemix on Flickr

The craft world and the tech world collide in this fun, hands-on activity.

FOR THIS PROJECT YOU WILL NEED

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

INTRO

In this issue we shall merge the craft world with the computer! We shall create our own computer circuit that uses the micro:bit as a power source and to process the input of our user and perform a corresponding output. And all of this is handled using common stationery items that will cost less than $10 to purchase.

In this project we will learn about

  • Loops, and how we can have loops running in parallel.
  • Conditional test and how they can be used to change the flow of our code.
  • Inputs and outputs, and how the computer will understand what to do.

So let’s get started!

HARDWARE

The main part of this project is the circuit, and for this we need a piece of A4 card, folded in half lengthways so that we have a firm base. Use glue to ensure that the card stays folded. If you are using cardboard then you can skip this bit.

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. To apply the tape smoothly use a cylindrical object to roll 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 to identify that it is for our GND connection. Repeat this process at the top of the card for the 3V connection.

For the next connection, 0, we shall use another full length of copper tape just underneath our 3V strip. Ensure that they do not touch! Mark this strip as 0, as it will connect to our micro:bit’s 0 GPIO pin.

For our next strip, 1 we shall position it underneath 0, not too close! But this time it will only be 2/3 of the length of the card. Why? Well 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 ? of the length of our card. Mark this as 2.

With all the tape applied we next clip our bulldog clips to the left edge of the tape, but why do we do this? When we later connect the crocodile clips their “teeth” will damage the tape rather quickly. Our bulldog clips give us a secure and tough connection.

Let’s make our first connection, between 2 and GND. This will be a momentary switch, a push button. For this we shall use a brass paper fastener. So using a pen or screwdriver carefully make a hole between the two strips. Then 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, the other touching 2.

Now using a little 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.

The next connection is between strip 1 and GND. For this we shall use an LED, a Light Emitting Diode. Our LED has two legs, the long leg called 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, called 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, we need to make sure that connection is the right “polarity” so that the flow of current is not stopped.

Our final connection will connect our buzzer. The buzzer has two wires, a red wire, which will connect to strip 0, and a black wire which connects to GND. If needed, strip the wires so that there is a good connection. Use a little copper tape to secure them down.

With the circuit complete, we now need to connect the circuit to our 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. Ensure that you 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 start writing code. Connect your micro:bit to a computer, and in a web browser visit microbit.org.

SOFTWARE

For this project we shall use the MakeCode editor. We can find this from the main microbit.org website by clicking on “Let’s Code” at the top of the screen. Then on the next screen click on the Javascript block editor.

In a few moments we will see the Make Code editor and just a quick refresher on the interface.

On the left we have a virtual micro:bit which we can use to simulate and test our code.
In the centre we have the palette of blocks that we can use to write code.
On the right we have the building area, where code is created using the blocks.

You will see that there are two blocks already in the coding area. “On start” is used once and runs when the micro:bit is powered up. “Forever” as you can guess, will continually run any code within it.

We shall start by adding code to “On start” and for this we need to click on “Advanced” and go to the “Pins” blocks. In there look for “…more” and click on it. Then 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.

But why have we done this? Well 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 shall go to the “Logic” blocks and use the “if true then..else” block.

Drag this into the forever loop as so. But this comparison test is not ready, we need a way to check one value against another, and for that we go back into the “Logic” blocks and use the “0 = 0” block.

Drag this and place it over “true”.

But there is still one step before we can move on, we need to 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. We can 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.

We can leave the second 0 as 0. Because we shall be checking to see when the pin is turned off. (Hint: It will turn off when we press the brass paper fastener down)

Now at this stage of the project, right click on the forever block and select “Duplicate” and it will copy all of our work so far. Move this duplicated block of code out of the way for now.

Back to our original loop and we now need to 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.

That is the first section of code completed!

Making the LED flash

For the second forever loop we start with the comparison that tests to see if the button has been pressed. But this time we would like the LED to flash four times when we press the button. For this we need to use the “repeat 4 times” block found in the “Loops” section. Drag this into the “if” part of the code.

But what do we want to happen four times? Well 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.

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 “Pins” section.

So now we should have three blocks of code that look like this.

Download the code

With all of the code complete, we now need to save our work, at the bottom of the screen is a disk icon (kids ask your parents!) and the word “Untitled” change this to Cardboard-Electronics 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 over, 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 it is complete the micro:bit drive will reappear in the file manager, and we can now press the brass Paper fastener button to trigger the code to run!

Well done, you have created your first cardboard computer circuit.

So what have we learnt?

  • How to build circuits using stationery
  • How to connect a micro:bit to a home made circuit
  • How to write code using MakeCode blocks

Learn More

WikiHow: Making a Simple Electrical Circuit

https://www.wikihow.com/Make-a-Simple-Electrical-Circuit

Electrical Circuit Projects for Elementary Students

https://learning-center.homesciencetools.com/article/circuit-science-projects-for-elementary/
https://www.shareitscience.com/2017/09/DIY-paper-circuit-board-games-STEM.html

An Electrical Circuit Quiz Board

https://www.teachingtreasures.com.au/K-10Projects/quizboard/quizboard.htm

Also In The February 2019 Issue

The craft world and the tech world collide in this fun, hands-on activity.

For twenty three years, since 1996, cars have used computers to control different parts of the car.

Synchronizing games with players from all around the world is no easy task.

A simple thought experiment sheds light on the dangers of AI. Can we stop the earth being buried in paperclips?

‘Files’ may be easy concepts for humans, but not for computers. What’s going on inside your operating system?

Two ways to play Minecraft with an overarching storyline. Experience the game like never before!

Helping kids fall in love with coding through Minecraft mods and Raspberry Pis.

A better, smoother way to direct your theatrical masterpiece.

How hackers can steal the messages you send over the internet, and how to tell if your communications are secure.

It’s not as simple as it seems. Can you solve this classic programming problem?

Ever wondered what happens when you connect to a website? Time to dive into the secrets of networking!

Links from the bottom of all the February 2019 articles, collected in one place for you to print, share, or bookmark.

Interesting stories about science and technology for February 2019.