• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Build Electronic Circuits

Build Electronic Circuits

Electronics explained in a simple way

  • Start Learning
    • Basic Electronics
    • Digital Electronics
    • Circuits
    • Practical Skills
      • Printed Circuit Boards
    • Microcontrollers
      • Arduino
    • Maker Lifestyle
      • Podcast
  • About Me
  • Blog
  • Products
  • Contact
You are here: Home / Mail Archive / Here’s how to play the Star Wars song with electronics

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

July 29, 2015 By Øyvind Nydal Dahl Leave a Comment

arduino-intro-Photo 19.08.14 14 43 39Today 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: https://www.build-electronic-circuits.com/what-is-arduino/ )

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:
http://youtu.be/cye_wiaqybk

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:
http://www.intmath.com/trigonometric-graphs/music.php

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:

https://www.build-electronic-circuits.com/products/ebook-2nd-edition

Keep on Soldering!
Oyvind

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.

Filed Under: Mail Archive

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Search:

Footer

Topics

  • Basic Electronics
  • Digital Electronics
  • Circuits
  • Practical Skills
  • Microcontrollers
  • Maker Lifestyle
  • Newsletter Archive

Social:

  • Facebook
  • Twitter
  • YouTube

Copyright © 2021 · Ohmify AS · Terms and Conditions · Privacy Policy