Skip to main content

Playing GarageBand with Arduino

GarageBand and Arduino Logo's

Hi guys, I built an 88-key piano using a Raspberry Pi Pico in a previous series. However, even though I added filters and amps, the sound was still too Midi. Therefore, I came up with an idea why I can’t use some extended software like GarageBand to output the sound and make it better. Then, let’s try it out!

If you are a music or Apple lover, I believe that you must hear GarageBand before. If this is the first time you hear this name, it doesn't matter. According to the Apple webpage, the claim that GarageBand is a fully equipped music creation studio right inside your Mac. Being a music amateur, I also agree that GarageBand is an excellent music software, and the most significant advantage is that it is free software. Hence, in this share, I will take it as an example to share how to play GarageBand with Arduino.

If you tried to make a keyboard using Arduino, you might face that the Arduino Uno can't use the Keyboard.h library. For that library, it only allows the 32u4 and SAMD-based boards (Leonardo, Esplora, Zero, Due, and MKR Family) to appear as a native Keyboard to a connected computer. Hence, this time, I used Arduino Nano 33 IOT to do this project, which used the SAMD21 Cortex®-M0+ 32bit low power ARM MCU.


Before we move on to the program parts, let's discuss how to play the GarageBand with Arduino. In GarageBand, there has a function call “Musical Typing”, you can play your selected software instrument using musical typing or the onscreen keyboard. In GarageBand, choose Window > Show Musical Typing. Then you can use this musical typing function.

Below, you can see an 18-key shown on the onscreen keyboard, and here it shows the layout of keys used for playing notes. For example, the note "C" is related to the character in the "A" keyboard.

Onscreen keyboard

Hence, we can try to make a keyboard that matches the appropriate characters through the Arduino Nano 33 IOT.


First, let’s talk about the Keyboard.h library. There are 8 functions included in the library. And in his project, I’ll mainly use 4 of them.

Keyboard.h functions

Keyboard.write() is very similar to and Keyboard.release() . But Keyboard.write() just keeps writing characters as PWM, if you press and hold the button, it will receive keep pressing the button instead of holding the button from GarageBand.


This is the pin map of the Arduino Nano 33 IOT. Also, as you can see, there are characters "x" and "z" for adjusting the octave in GarageBand.

#include "Keyboard.h"

const int c = 2;
const int cs = 9;
const int d = 3;
const int ds = 10;
const int e = 4;
const int f =5;
const int fs = 11;
const int g = 6;
const int gs = 12;
const int a = 7;
const int as = A0;
const int b = 8;
const int x = A1;
const int z = A2;

This is the setup of the MCU.

void setup() {
  pinMode(c, INPUT);

  pinMode(cs, INPUT);
  pinMode(d, INPUT);

  pinMode(ds, INPUT);

  pinMode(e, INPUT);
  pinMode(f, INPUT);

  pinMode(fs, INPUT);
  pinMode(g, INPUT);

  pinMode(gs, INPUT);
  pinMode(a, INPUT);

  pinMode(as, INPUT);
  pinMode(b, INPUT);

  pinMode(z, INPUT);
  digitalWrite(z, HIGH);

  pinMode(x, INPUT);

  pinMode(TAB, INPUT);

Then, in the main loop, which is very easy to understand. When the button is pressed, the keyboard is pressed and prints the characters.

void loop() {
  if (digitalRead(c) == HIGH) {'a');
  if (digitalRead(cs) == HIGH) {'w');
  if (digitalRead(d) == HIGH) {'s');
  if (digitalRead(ds) == HIGH) {'e');
  if (digitalRead(e) == HIGH) {'d');
  if (digitalRead(f) == HIGH) {'f');
  if (digitalRead(fs) == HIGH) {'t');
  if (digitalRead(g) == HIGH) {'g');
  if (digitalRead(gs) == HIGH) {'y');
  if (digitalRead(a) == HIGH) {'h');
  if (digitalRead(as) == HIGH) {'u');
  if (digitalRead(b) == HIGH) {'j');
  if (digitalRead(x) == HIGH) {'x');
  if (digitalRead(z) == HIGH) {'z');
  if (digitalRead(TAB) == HIGH) {;

Before you download the program into the MCU, in “Device Manager” you can only see the “Arduino NANO 33 IOT” in the Ports.

Device Manager showing “Arduino NANO 33 IOT” in the ports

After you download the program into the Arduino Nano 33 IOT, you will find that you still can’t use the Arduino to type anything. Then you can open the “Device manager” again, and you will see that there has an alert next to the Arduino Nano 33 IOT.

Device Manager now with Alert

Then you can right-click the “Arduino Nano 33 IOT”, and click “Update driver”.

Click and update driver for “Arduino NANO 33 IOT”

Choose "Browse my computer for driver software", and click Next.

Browse my computer for driver software

Click “Let me pick from a list of available drivers on my computer”, then click “next”.

Let me pick from a list of available drivers

Then, select “USB Input Device”, and click “next”.
select “USB Input Device”

Finally, click “close”. And you can open “Notepad” or anything else to test whether your MCU types the characters correctly.

open “Notepad” to test your MCU types the characters correctly

Here is the demonstration of the project.

Finally, I hope you enjoy this project. Last but not least, in this sharing, I take GarageBand as an example. If you use any other music software or composition software, you can use your PC's keyboard to first check the corresponding button for each note and change the pin mapping to the MCU.

JulianWong has not written a bio yet…
DesignSpark Electrical Logolinkedin