How To Make Music With An Arduino
Maybe your like
Embed the widget on your own site
Add the following snippet to your HTML:

In this video I explain how you can use an Arduino to make music using just a speaker and a resistor.
Read up about this project on 
How to make music with an Arduino
Code_and_Make35 38,531
Code_and_MakePublished February 25, 2018 © CC BYHow to make music with an ArduinoIn this video I explain how you can use an Arduino to make music using just a speaker and a resistor.
BeginnerFull instructions provided38,531
Things used in this project
Hardware components | |||||
![]() |
| × | 1 |
| |
![]() |
| × | 1 | ||
![]() |
| × | 1 | ||
Software apps and online services | |||||
![]() |
| ||||
Story
In this video I explain how you can use an Arduino to make music using just a speaker and a resistor.
Like many similar projects, this one generates tones that match the notes of a piano. Unlike many of these projects, however, this one does not use a lookup table to obtain the frequencies. Instead, the tones are generated using a calculation. The calculation accepts a number from 1 through to 88. This number correlates to a key on an 88-key piano.
The Arduino library offers a tone() function which can be used to generate square-wave tones, but this function is unable to generate tones under 31Hz. An 88-key piano has a few notes with frequencies that fall below 31Hz. So, if you’d like to generate the full range of notes from an 88-key piano, the tone() function cannot be used. Instead, I will show you how to generate square-wave tones using a simple delay.
This project works at a microsecond level. A microsecond is one millionth of a second. This project makes extensive use of the Arduino library’s delayMicroseconds() function, but therein lies another minor issue, as it cannot reliably delay for more than a few thousand microseconds, which this project sometimes needs to do, so I will show you how to overcome this too.
One last thing about this project is that, despite the issues described above, the code for the project is really rather small, as the code just about fits onto a single screen (your resolution may vary!). To be fair, that is without any code comments, but a link to fully commented code is available in the video description.
I hope you enjoy this project!
How to install the Arduino IDE in Ubuntu
Read moreSchematics
Wiring
Connect speaker to GND and pin 12 via a resistor.
Code
Project code
Credits

Code_and_Make
1 project • 9 followersFollowComments
Related channels and tags
- audio
- music
Tag » Arduino 8 Ohm Speaker Circuit
-
Connecting An 8 Ohm Speaker To Arduino - General Electronics
-
Play Wave With Sd-card And 8ohm Speaker - Audio - Arduino Forum
-
8 Ohm .5w Speaker Output To Arduino - Project Guidance
-
How Do I Connect An 8 Ohm 1 Watt Speaker To Arduino? - Quora
-
Arduino 8 Ohm Speaker
-
Tutorial 7: Arduino Melody Circuit For Beginners - Starting Electronics
-
Question About Driving 8-ohm Speaker : R/arduino - Reddit
-
Arduino Basics: Making Sound : 5 Steps (with Pictures) - Instructables
-
Results For 8 Ohm Arduino Speakers Kit - AliExpress
-
Arduino Speaker 8 - Circuits Intégrés - AliExpress
-
Hooking Up 8 Ohm Speaker To Arduino
-
Lab: Tone Output Using An Arduino - NYU ITP
-
Buy Arduino 0.5W 8Ohm 56mm Diameter Speakers Electronic ...
_ztBMuBhMHo.jpg?auto=compress%2Cformat&w=48&h=48&fit=fill&bg=ffffff)





