Browse over 10,000 Electronics Projects

Here’s how to play the Star Wars song with electronics

Here’s how to play the Star Wars song with electronics

Today is the last day.

I’m teaching a course at betahaus in Berlin.

And tonight is our last session.

It’s also my last day in Berlin (for now) — but more on that some other time.

We’ve had a lot of fun in the course.

One thing I taught was how to play a melody using an Arduino.

…and I thought that might be interesting for you too.

(If you don’t know what Arduino is, you can learn about it here: )

Here’s how to create a melody player:

In the last session, they (the students) learned to play a tone with a piezo speaker, using the tone() function.

By combining many tone() commands, you can create a melody.

Just find the notes of the song you want to play (easy to do with Google).

There’s also a function called noTone() to stop the tone from being played. By combining these two functions with the delay() function, you can play melodies.


Here’s an example:

The tone function needs the frequency of the note you want to play. To find the frequencies of musical notes, you can check out the table on this page:

If you have an Arduino and a piezo speaker, I would highly recommend you to try it out. It’s a fun exercise, and it gives you something cool to show off to your friends.

No idea what Arduino is, or how to get started?

I have a guide — “Get started with Arduino in less than a day” — that you’ll receive as a bonus if you get one of my eBook bundles here:

Keep on Soldering!

PS! It’s soon time to launch the next round of my online course. I just need to finish some of my projects before taking on something new. I’ll keep you posted.

Copyright Build Electronic Circuits