Micro:bit – Simple Compass

One of my favorite things about the micro:bit is that it comes with several sensors right on the board that can be used without any additional hardware. However, if you’re just starting out with a micro:bit, it can be a little challenging to know exactly how to use them all. In this post, I’ll be explaining the compass sensor – showing how to use it and walking through a simple program to turn your micro:bit into a working compass.

The compass sensor on the micro:bit

For this program, I’ll be using the micro:bit blocks in Microsoft MakeCode. (Scratch 3.0 has a Micro:bit extension, but as of this writing, it does not include a compass sensor block.) If you haven’t used MakeCode before – don’t worry. It is very similar to Scratch. The programming blocks are in the middle section of the screen, the programming area is on the right, and an image of a micro:bit appears on the left that will simulate how your program will appear on an actual micro:bit.

The micro:bit programming environment in MakeCode

The compass heading block is found in the Input section of blocks. The corners are rounded – making this a data block. That means that it can be used anywhere in the code that you would normally use any other data block (such as a variable).

The compass heading block is constantly populated by the compass sensor on the micro:bit. As you physically turn the micro:bit, the value of the block will adjust to the current compass heading value in degrees. This will be an integer between 0° and 359°. (More info about the points of a compass can be found in this Wikipedia article.) Note that in this post, I’ll be discussing degrees and using the degree symbol (i.e. 50°) but it is important to understand that the actual value returned by the sensor will be a number. There is no need to worry about the degree symbol – it is assumed by the program.

Compasses typically divide direction into various ranges of degrees. These can be quite specific (such as Southwest by South) which is useful when navigating but probably more detailed than we need for this project. We’re going to make a simple 8 point compass with the following directions: North, Northeast, East, Southeast, South, Southwest, West, Northwest.

The exact degrees of an 8 point compass

To create our compass, we need to determine the ranges of degrees that will apply to each direction. Each direction must have a minimum and maximum degree value and anything that falls between those should be counted for that direction. For example, a heading of 178° should fall within the range of degrees that is close enough to south on our compass.

By finding the midpoint between two directions, we can define the edges of the degree ranges on our compass. In this example, East is defined as any degree between 67.5° and 112.5°

We can expand that out to the entire compass to determine our ranges for each direction.

Dividing the compass into 8 ranges

I’ve included the values in a spreadsheet for easy access as well.
Spreadsheet Download. (Open Document Spreadsheet format.)

Numerical List of Values for Compass Program

The compass program is fairly simple and uses If, Else If, and Else blocks. (This could be a good project to learn basic programming control flow logic.) We’ll need the following blocks:
From the Logic Section:
1. If Else
2. And
3. Or
4. Comparative (greater/less than)
From the Basic Section:
1. Show LEDs
2. Pause

The program will use a series of If Statements that determines the output on the display based on the current compass heading value. The program below will display the word “North” when the heading value is exactly zero.

A simple example showing how to use a Compass block

Of course, we don’t want to use exact values – we want to use the range of values that we determined above. We can combine multiple Comparative blocks by using the And block. In the example below, the ranges for Northeast and East are determined by determining if the compass heading value is greater than the minimum and less than the maximum value for each range. (I’ve used a greater than or equal block but you could also use a simple greater than block. The value of compass heading is an integer so it will never match exactly to a decimal point value.)

Programming the compass ranges.

Notice the use of Else If partitions in the code above. This functionality is hidden by default, but you can add them to an If Else block by pressing the plus sign at the bottom.

I’ve used the Show LEDs block to draw an arrow indicating the compass direction. Alternatively, you could use a Show String block to display abbreviations such as “N” and “SW” or even the full direction name. (Keep in mind that strings greater than one character will need to scroll which will slow down how quickly you can get a new direction.) I’ve also used a pause block to wait 500 milliseconds (half a second) so that the display isn’t changing too quickly. The code is all placed in a forever block so that it will run as long as the micro:bit is on.

For most direction range, you will use an And block. However, the North block is unique because the minimum value is a larger number than the maximum value. (Remember, it is a circle so it resets to 0° after 359°.) Because of this, you’ll want to use an Or block for the North range. Because the value of compass heading will never be greater than 359 or less than 0, you don’t need to worry about defining the maximum or minimum values.

An Or statement to determine if the compass is pointing North

Microsoft MakeCode has a cool feature when using the compass blocks that allows you to test the code before loading it onto your micro:bit. A small arrow will appear on top of the micro:bit on the left side of your screen. You can drag this with the mouse to different directions to make sure that your code is working as expected.

The symbol on top can be rotated to test the compass function. 270° is in the West range and 194° is in the South range.

Finally, I like to add a message that will display in case there’s an error. If the sensor fails or is unable to determine the direction, the micro:bit should not display an arrow.

Any time you load a program involving the compass onto the micro:bit, you must first do an exercise where you tilt the micro:bit to move a blinking dot until it fills the screen. This orientates the device and makes sure that the compass readings are correct. You only need to perform the first time you load the program. Afterwards, it will load directly to the compass.

Once you’ve loaded the program onto your micro:bit, you can turn and the arrow will change to indicate the direction you are facing. The compass program works best when the micro:bit is laying flat. (If you hold the micro:bit upright, it will probably not work as expected.)

A few compass directions shown on the micro:bit

You can find the whole program here: Simple Compass for micro:bit.

Programming a TI-85 Graphing Calculator – Revisting the 1990’s TI-BASIC

In my previous post, I discussed how I cleaned out and restored my old TI-85 Graphing Calculator after finding corroded batteries inside.

After finally getting it to turn on, I immediately started reliving my high school experience. It was honestly kind of surprising how quickly my memories came back to me. Despite not using the calculator for almost two decades, I was able to remember and use many of the functions and my fingers seemed to instinctively know where each letter was on the keyboard. Maybe it shouldn’t have been surprising though, that thing was an extension of my arm during many classes in high school and college and I spent a lot of free time reading the manual and learning the simple programming language that came pre-installed. (ProTip: This is not how you become popular in 1995.)

I had gotten the calculator out of storage to see if any of my old high school programs were still installed. Unfortunately, the TI-85 did not come equipped with permanent storage so programs needed power to survive in RAM. Mine were all lost.

I was probably feeling overly nostalgic because I started working on a new program for the calculator. Appropriately enough for a calculator, my program is called Simple Math. It takes two numbers and then adds, subtracts, multiplies, or divides them. Obviously, this is a bit redundant to the calculator’s basic functions. I was more interested in working with the TI-BASIC programming language than I was with creating something useful.

The TI-85 was limited to just 8 characters for the names of variables, functions, and files (as were most of computers of that era). So the program is actually called SMPLMTH. When loading it up from the Programs menu, this is what you see.

The Simple Math input screen

The program has a greeting and then asks for two numbers. The TI-85 has two methods of asking for user input. The first (and the one I’ve used here) is the Input command. It simply displays a question mark and then waits for the user to type in a value.

An example of the code for Simple Math

The second method is using a Prompt command. This is very similar except that the name of the variable being loaded is displayed for the user.

Using the Prompt function in a simple program on a TI-85

After the user enters the numbers, the program displays the chosen numbers and then asks which mathematical function should be applied.

Imagine a calculator program that can do all of this?

The TI-85 cannot concatenate strings and numbers so the line displaying the chosen numbers was fairly difficult to figure out. To be used in a sentence, the variables containing numbers had to be cast as strings. In modern programming languages, there are simple commands that can easily cast values to other data types, but not so on the TI-85. For example, in Excel, you would use the TEXT function to convert numbers to strings. (Although many can do it implicitly, including Excel. The TEXT function in the example below is not necessary to get the same result.)

Casting number values as text in Microsoft Excel.

To accomplish it on the TI-85, I needed to use a special function called St⯈Eq (String to Equation). It wasn’t as simple as just dropping the variable into the function. I ended up needing to do a Linear Regression on the variable and then substring the result into a new string variable. (I can’t take credit for the idea, I found the code on Technicalc.org.) That’s obviously needlessly complex but I think it was the only solution available.

It also highlights one of the major difficulties of writing TI-BASIC – the use of non standard characters. Converting strings required the Eq⯈St command. Storing a value to a variable requires another arrow character. For example, 60 → VarName. This is significantly different from other version of BASIC which used the LET command (ie. LET VarX=95). The arrow assigning values reminded me a little of the R syntax, although that can easily be typed with a keyboard (i.e. VarX <- 60).

A few of the special arrow characters on the TI-85

I’m using a unicode arrow characters (U+2bc8 and U+2192) to replicate the look of these characters, but I have no idea what the characters actually are. They definitely make programs harder to write since you can’t use a regular text editor. As I recall, to write programs for a TI-85, you needed to use their TI-GRAPH LINK software. It was a very proprietary model.

Once you entered your numbers and made your calculation choice, the Simple Math program used an IF statement to determine which function to perform and output the result.

The final output of the Simple Math program

Despite the program being pretty useless, it was interesting to work in such an old environment and think about what has changed and what has remained the same in the years since I last used it.

Some functions like IF statements are very similar to their modern equivalents (although I needed to nest the IF statement to have multiple conditionals). Other things, like the lack of local variables were surprisingly different. (The variables that I used in the program were automatically global and accessible by any other program or calculation.) Even in this little program I was able to find several examples of increased efficiency and simplified syntax in modern programming languages.

Using the NUMA global variable outside of the Simple Math program.

It was also interesting to think about the possibility that I might be one of the only people in the world to write a program for this particular piece of hardware in 2019. Although that might not be true because the internet still has a surprising amount of resources of programming older TI graphing calculators. Perhaps there are more hobbyists out there than I realize.
ticalc.org has a ton of programs, examples, and guides for the TI-85
TI-Freakware has a guide to TI-BASIC for the TI-85.
TI-Basic Developer has a ton of guides and programs available (although apparently for later TI versions)
Wikibooks has a TI-Basic manual, but once again it seems more focused on later calculators. (I found a few commands that are not compatible with the TI-85.)
The University of Arizona maintains a website of TI-85 lessons.

The TI-85 is a bit of a relic now. Between the monochrome screen, tiny amount of memory, difficulty of transferring data and programs, and non-standard characters, it is hard to think of a compelling reason to use it today. Making kids learn coding on this in the age of languages like Scratch and Python would be needlessly difficult. However, playing around with it for an evening reminded me of what a remarkable piece of technology this was. Decades before anyone had conceived of a smartphone, millions of high school kids carried a programmable computer in their backpacks that wasn’t that much bigger than a modern larger smartphone (at least in length and height, not so much in terms of width).

Size comparison of a TI-85 and a Google Pixel 2 XL

Unfortunately I am not able extract my example program off of the calculator. I’ve long ago lost my graph-link cable and even if I had it, my computer doesn’t have a DE-9 connector. Also, the Graph-Link software for the TI-85 doesn’t support versions more recent than Windows 95.

If you’d like to see the program, I’ve typed up the code below. The variables NUMA and NUMB hold the numerical values (REAL type in TI-BASIC) and NUMAS and NUMBS are the String versions. It is released under the MIT License.

:Input NUMA
:Input NUMB
:Linr {0,1},{NUMA,NUMA
:sub(X,1,lngth X-3 → NUMAS
:Linr {0,1},{NUMB,NUMB
:sub(X,1,lngth X-3 → NUMBS
:Disp "1. ADD"
:Disp "2. SUBTRACT"
:Disp "3. MULTIPLY"
:Disp "4. DIVIDE"
:Input ANS1
:If ANS1 == 1
:If ANS1 == 2
:If ANS1 == 3
If ANS1 == 4
:Disp round(NUMA/NUMB,2)

TI-85 vs Potassium Carbonate: A Cautionary Tale

This year at the R Studio conference, I heard an excellent presentation from Mary Rudis on teaching statistics with R at community colleges. (I don’t teach at that level, but enjoy learning more about education techniques.) She mentioned in her talk that many students get their start in stats programming using graphing calculators.

This comment was just an aside, but it got me thinking about my own programming history and some of the early programs I wrote on my TI-85 graphing calculator when I was in high school and college to help calculate equations in my science and math classes. For example, I remember writing a simple program where you could enter the mass and distance of two objects and it would calculate the gravitational force.

I came home from the conference feeling nostalgic about my early programming work. I wanted to see if any of my old programs were still saved on my calculator. I dug it out of a storage bin and opened up the back panel to put in some batteries. Unfortunately, there were already batteries in there…

Potassium Hydroxide forming a Potassium Carbonate salt around the seal of the battery. (Note, be smarter than me and don’t handle them without gloves.)

I don’t remember what year those batteries were installed, but they expired 16 years ago. At some point, they leaked their internal potassium hydroxide, which forms a salty crystal called potassium carbonate once outside of the battery. The inside of the battery compartment and several of the springs were caked in the stuff. (This is a skin irritant, a fact I discovered when I picked up the batteries. You should wear gloves when handling leaky batteries.)

Potassium Carbonate salt around the springs in the TI-85 battery holder.

Using a Q-Tip dipped in white vinegar, I was able clean out the area. Vinegar is a mild acid so it neutralizes the strong base of the potassium carbonate. I tried hard to avoid leaking any liquid inside of the calculator.

After giving the calculator some time to dry out, I loaded it up with fresh batteries and crossed my fingers.

The TI-85 graphing capabilities.

It powered right up! All the buttons and the screen seem to work fine. Thankfully, I haven’t noticed any adverse performance effect at all.

I was sad to realize that the TI-85 did not have any form of permanent storage. (It was created in the days of the 3.5 inch floppy disk, after all.) All the variables, programs, and custom functions are stored in memory – which required power to maintain. The calculator had a backup coin cell battery (to preserve power when changing the AAA batteries) but that had long since expired as well. Whatever programs I had written had long ago been erased when the calculator ran out of power.

Despite losing all that early work, it’s been surprisingly fun to have this piece of my teenage life back. I’ve done some simple graphing and even written a small program. (More on that later.)

It was a good reminder to always remove the batteries from electronics that are not going to used for awhile. I was lucky that the leaked batteries didn’t cause any damage to the calculator. The TI-85 may have escaped this battle unscathed, but leaking batteries can cause irreparable damage to electronics. Don’t do what I did and let them sit for over a decade in storage.

Edit: I’ve added a new post about programming the TI-85.

Introduction to Paper Circuits with an LED Valentine’s Card

Creating a paper circuit in a card is a very fun project that teaches kids some basics about electronics and makes a fun gift. I have designed a Valentine card with a simple circuit design that you can download and craft.

The completed paper circuit valentine card all lit up

To create the card, you’ll need an LED light, conductive copper tape (the guideline is sized for quarter inch tape but other sizes should work), and a 3V coin cell battery. I’m using a CR1620 battery in this example but other 3V sizes work just as well. I also recommend that you print the card on a heavier stock paper so that it can hold the weight of the battery and light.
Here are the links to download the card in PDF format.
Valentine Card PDF (US Letter)
Valentine Card PDF (A4)

I’ve learned the hard way that before applying any tape, you should always make sure the LED works. You can easily test this by placing the legs of the LED directly on the battery. Make sure that you put the longer leg on the positive side of the battery.

Testing an LED bulb

The card is marked on the front and back with some guides to help you prepare it. On the front side there is a dark square indicating where the light bulb will pop out. I cut out this out with an X-Acto Knife but you could also use a hole punch if you have one long enough.

The inside of the card has guidelines showing where the copper tape, LED, and battery should be applied.

Apply the copper tape to the card following the guidelines. Try to keep the tape as continuous as you can by folding over the corners instead of breaking the tape. This creates a stronger circuit by having a continuous line for the electrons to follow. (You can also overlap the corners if the tape is broken but that risks a weaker or broken connection.)

Making a corner from copper tape

To put on the battery, create a tape roll so that it is sticky all around. Place the roll on the battery spot and firmly press down to create a good connection with the tape underneath. Then stick the battery on top of the roll with the negative side down. (The negative side of a coin cell battery is usually textured.)

A roll of copper tape to attach the battery to the circuit

Finally, bend the legs of the LED out so that they point in opposite directions. Make sure you keep track of which one is the long leg. Place the LED on the spot indicated with the legs overlapping the tape on either side. Make sure that the longer leg is on the positive side or the circuit will not work. Secure the legs with two more small pieces of tape. This will complete the circuit across the broken spot in the tape.

Securing the LED with copper tape above and below the LED legs.

When the card is folded on the score line, the copper tape will touch both sides of the battery and allow the electrons to flow through the circuit – lighting the LED in the middle.

Inside of completed Valentine Card

The card was created in Inkscape. It uses the font Destructo Beam by Blambot Comic Fonts.
The card is available under an International Creative Commons 4.0 by-nc-sa license so you are free to modify the card if you’d like. (Let me know if you do, I’d love to see what others do with it).
Valentine Card SVG format (both US letter and A4 included).

Additional Examples of Nested If Statements

In my previous post, I discussed an issue in Scratch relating to Nested If statements. I think that by limiting the If statement to only one conditional (an If condition or an Else condition), the concept of multi-conditional statements has been made more difficult that it should be. I believe that Nested If statements are more complicated for a beginning programmer to understand than Else If statements.

I thought I’d take a look at how a few other programming languages have handled multi-conditional statements.

There’s an alternative to Scratch called Snap! designed by UC Berkeley. (It’s actually based on Scratch and looks very similar.) The language has less focus on being immediately intuitive and extends Scratch with blocks that handle several advanced programming concepts.

I used Snap! to write the same basic emoji program that I created in Scratch. Using the basic available blocks, it looks very similar. To use multiple If statements, I had to nest them inside the previous Else statement.

I did like one difference that stood out from Scratch. The nested Ifs were automatically set in alternating shades to make them stand out. This increased the readability and made it a little easier to understand what was going on.

Snap! is designed both to teach younger children and adults programming concepts. There are a few additional blocks in the base version of Snap! that you won’t see in Scratch, but it also comes with several libraries that add even more complexity and advanced techniques. The library “Multi-branch conditional (switch)” allows (as the name implies) multiple conditionals in an IF statement. It adds several new commands to the Control blocks. One of them is a cases block that allows for multiple else if statements to be added.

Else If built in Berkeley’s Snap language

The black arrows in the bottom right add or subtract spaces to insert more Else If statements. The final statement can be used for an Else block that runs if none of the other Else If blocks run. The syntax and visual layout takes a little getting used to, but I do like this better than nesting all the If statements inside of each other.

Another language that people encounter early in their programming careers is the cell formulas in Microsoft Excel. Up until recently, multiple If statements needed to be nested within each other, similar to Scratch. I’ve spent many years in my career writing overly complicated formulas like this.

Nested If Statements in Excel

The commas dividing the IFs and the stack of closing parentheses at the end make the typo potential high and the readability low. Thankfully, in newer versions of Excel (and Google Sheets), there is a function called IFS which handles multiple conditionals much more smoothly.

The IFS method of handling multiple if statements.

The format of this is IFS(Condition 1, Result 1, Condition 2, Result 2, Condition 3, Result 3 and so on. The result for the first condition that is true will execute. There isn’t a default ELSE, so to replicate that functionality you can just add the word TRUE as the final condition check. If none of the previous conditions were met, that one one will always execute.

Finally, it worth mentioning that many other programming languages have a command called Switch or Case. (You may have noticed that the multi-conditional block in Snap! is called cases.) Functionally, this behaves much the same as an ELSE IF. A series of cases are evaluated and only the one that matches a condition is executed. Here is an example of the emoji program written in JavaScript with a Switch.

JavaScript Switch Example

The syntax here shows a key difference from the ELSE IF logic. 1.) There is no comparison operator (===, >=, etc) required – it is assumed by default. The switch statement takes a variable or value and then compares it with each of the cases. 2.) Unlike an IF statement, the program will evaluate all cases even after finding a match. To prevent this, the break keyword is included in each case result. When encountering a break, the program will move on to whatever follows the switches final curly bracket. 3.) The default keyword functions in the same way as the terminating ELSE in and IF statement. This will run if none of the other cases were met.

Some programmers prefer to use IF statements for comparison operators such as equality or greater than or equal to. Switch is often used for checking the value of strings, as in the emoji code above. For example:

if(Variable1 >= Variable2) {
  console.log("The first number is higher");
} else {
  console.log("The second number is higher";)

switch(Variable1) {
  case "Breakfast":
    console.log("Good morning!")
  case "Lunch":
    console.log("Good afternoon!")
  case "Dinner":
    console.log("Good evening!")
    console.log("Good day!");

Honestly, the choice of using an IF THEN ELSE or a SWITCH comes down at least partially to programmer preference. There is some speed variability between the two methods that can be analyzed if optimization is needed, but generally speaking, either method can be used for both of the above situations.

Regardless of which methodology is used, the multi-branched conditional statement is an important concept for new programmers to learn. The nested if statements in Scratch can work for simple projects, but for more advanced work, programmers will need to learn improved techniques.

Nested If and Variable If Statements in Scratch

I love using Scratch to teach children and others about coding. By using blocks instead of syntax, it has simplified coding to make it accessible even for very young children. I love that it has eliminated the need to learn some of the more difficult aspects of coding such as where curly brackets and parenthesis go when a person is first learning about things such as variables, control flow, and loops.

There are a few areas where I wish Scratch hadn’t simplified quite so much. I understand the need to keep things simple for young learners, but in some cases, over simplification inadvertently leads to more complex situations. The primary example of this is the limitation of the IF THEN ELSE to only one ELSE statement.

For those not familiar, the IF THEN ELSE statement is used to control which parts of the code run based on variable conditions – often times input from the program’s user. (This is called a conditional logic or control flow.) The programmer can put in several alternate pieces of code – which one runs depends on the values currently in the program. For example, if a number is greater than 50, then the program will say it is a big number. Else, the program will say it is a little number.

Example of an IF statement in Scratch

The problem is that programs often have more than two alternatives that might need to run. There could be three, ten, or even a hundred alternatives. In most programming languages this is handled with an ELSE IF statement (or alternatively a SWITCH statement). If the first condition is not met, the program will check the next one. If that one is not met, it will continue checking down the list until a condition is met or it reaches the end of the list.

To illustrate this, I’ve written a simple program that has four conditions. The user is asked to enter a letter. A different emoji is returned for each letter – including a sad face in case none of the requested letters was used.

Here is the program in a language called JavaScript. The variable emoji contains the user input. The first IF is just written with “if” but each subsequent one is written as “else if”. Finally, an “else” catches anything that didn’t match earlier.

Here is the same example in a language called Python. This one uses the slightly more hard to read syntax of “elif” which is short for “else if”.

This syntax is clean and easy to read. You can follow the logic easily and determine what will happen based on the value of the variable.

Unfortunately, Scratch lacks the ability to have multiple conditionals in a single IF statement. There is a workaround called the Nested If statement. Essentially, this is just a regular IF THEN ELSE statement, however, instead of putting something like a message to be displayed to the screen in the ELSE, you put another IF statement. This can be repeated over and over again until you have all your conditionals. This can get very complicated very quickly.

Here is the same program written in Scratch. Notice how each ELSE statement has another IF THEN ELSE statement inside.

Scratch Nested If Example

What if you want to add more letters and emojis to the code? To add another condition into the logic flow, you drag a new IF statement into the ELSE statement of the last IF statement. This can be repeated as often as needed.

While not problematic at first, it can become overwhelming in short order. In this example, we display a separate emoji for letters A through H. (Also out sad face is displayed if none of those letters were used.)

Look at the bottom of this code block – there are 8 block closures all in a row. Imagine if we had an emoji for all 26 letters!

This can be very confusing, especially for younger children learning to code. It’s also a fairly archaic way to code – more reminiscent of programming languages from the 80s then those of today.

This has been discussed in Scratch forums in the past but does not seem to have generated much interest.

Other block languages have added this functionality in a very eloquent way. Here’s an example from Microsoft’s MakeCode. The user simple clicks the plus sign at the bottom of the block to add a new else if statement.

To keep things a little easier to read (like the MakeCode example), I like to use an alternative method for keeping track of multiple IF statements. I use a variable to track if an IF Statement has been used, which allows me to keep the various IF statements separate. This is quite a bit easier to read.

Here is the original program again, but now using a variable (emojiCheck) instead of multiple nested IF statements.

The emojiCheck variable is initially set to zero but if any of the IF conditions are met, it is changed to one.

The final IF statement checks for the value of emojiCheck. If it’s zero, that means that none of the previous IF conditions were met and the sad emoji face is displayed. If any of the previous IF statements were met, this block does not execute.

It is not perfect, but I think this Variable If method may help new users learn the code without the confusing aesthetics of a nested if statement.

All of the code in this example is available to those interested.
Emoji Code Examples
The Scratch programs are also shared with additional comments included in the code.
Nested If example in Scratch
Variable If example in Scratch

Edit: I added a few more examples from other programming languages in another post: Additional Examples of Nested If Statements.

First Projects with the Makey Makey: The Fruit Keyboard.

A gaming keyboard wired up and ready for action!

One of the easiest ways to use your Makey Makey is to hook up a simple gaming keypad with the included alligator clips. The six alligator clip spaces on the Makey Makey can replicate the 4 arrow keys on the keyboard, the space bar, and a mouse click. Any object that can conduct a small amount of electricity such as fruit, play-dough, water, or even other people, can be connected to the Makey Makey and used as those keys. When you touch the “keys” while also holding the ground wire, the computer will react as if you are using a regular keyboard.

You can write programs for the Makey Makey using included blocks in Scratch 3.0, but you can also just plug it in and use the keys right out of the box. This is what I did for my first project. I found a website that replicated a few old arcade games, plugged in my Makey Makey, and had some fun!

A noodle keyboard.

My first attempt at a keyboard was with a few leftover spiral noodles from lunch. I jabbed the alligator clips through the center and tried to play a few games. Unfortunately, this did not work very well. Noodles, as it turns out, are not meant to be repeatedly pressed. They fell apart quickly and I struggled to maintain connection to the Makey Makey. You definitely want to use something that can has a bit more structure and can hold its shape when being poked.

Playing a game on the banana keyboard

Bananas seem to be one of the most common things people use as keys when starting out on the Makey Makey. This is for a few good reasons: they conduct electricity well, they are firm enough to be used as keys, and playing a game on bananas is just plain fun! It’s hard to overstate how unique the experience is.

Playing an arcade game on a banana keyboard with the Makey Makey.

At first I had the connections clipped to the stem of the banana. This worked pretty well at first, but perhaps because of the strong spring in the clip, they wore through the bananas after a few games. Eventually I switched to just jabbing the clip inside the banana. This seemed to provide a more reliable connection.

The Makey Makey Banana Keyboard in action

The Makey Makey allows you to mix and match all sort of different things. You don’t need to only use bananas. I mixed it up a little for another game by using bananas as the arrow keys and an apple as the firing trigger (space bar).

Firing with an apple

You can see in the picture above that I’m holding the ground wire in my left hand pressing the bananas to move and squeezing the apple to fire. It adds quite a bit of fun to these classic games to mix them up with a creative keyboard.

Ready the apple and FIRE!

After playing all of those games, you’ll probably work up an appetite. That’s where your Makey Makey fruit keyboard really shines. Its the only keyboard you can eat when you’re done!

The keyboard you can eat!

Welcome to Circuits and Code

Hello and thank you for visiting this new site!

I decided to start this site after watching an excellent keynote at the 2019 RStudio Conference by David Robinson. He described the huge benefits of documenting what you are learning on twitter, blogs, videos, and even books. (The video is available for anyone interested.) Writing about what you are learning can help you understand the topic more thoroughly and also help others learn it as well.

While his talk focused primarily on data science and R, I was very intrigued about his ideas for a subject I’ve recently been learning about – electronics and microcontrollers. I’m still very new to both fields but I’ve really enjoyed what I’ve learned so far. I’ve purchased some educational kits to work on and I thought it would be interesting to write about my progress as I work through the lessons.

I’m sure I’ll make mistakes along the way, but by sharing them hopefully others can learn from them – and help me do better.

In addition to documenting the electronic lessons that I’m working on, I’ll also be writing about subjects in which I am much more experienced. I’ve worked in database technology for most of my career. I’ve been writing SQL for about 15 years and have worked with many different databases. I’ve trained newer developers on optimization techniques and thought it would be fun to share some of my experiences here as well.

Finally, I also have the incredibly fun job of teaching beginning coding skills to elementary school students. Seeing kids pick up on new skills and get excited about coding is one of my very favorite things. I’ve written several lessons in Scratch and I’ll be sharing some of those here as well.

I’d love to get your feedback or questions on the posts as they come up so feel free to reach out. You can comment here on the blog or find me on Twitter at @CircuitsAndCode.