Course Content
The Arduino UNO
In the following three lessons, you will get to know your microcontroller - the Arduino UNO. You will learn more about its history, its functions, and most importantly: how to power it.
0/3
The Arduino IDE
For beginners, the Arduino IDE (Integrated Development Environment) is usually the first choice – and for good reason. You can program all Arduino boards with it and manage libraries for sensors, displays, etc. It also features the "Serial Monitor," where you can output data and troubleshoot.
0/2
Your first sketch
In the following lessons, you'll get to know the basic structure of an Arduino sketch and write your own programs. Let's get started!
0/2
The Serial Monitor
Now let's turn our attention to the Serial Monitor – a feature of the Arduino IDE that you will use in virtually every one of your projects.
0/2
Variables
No programmer can avoid variables. In the following lessons, you'll learn what types there are and what you can do with them.
0/3
Controlling an LED
Now it's time for more hardware! In the next lessons, you'll connect an LED to your Arduino. You'll first turn it on and off with a button. After that, you'll build a dimmer to control the brightness of the LED.
0/6
Lie Detector
Discover the entertaining side of electronics by building your own simple lie detector with your Arduino. This fun project uses basic components to measure skin resistance changes when someone might be telling a fib, perfect for adding some playful suspense to your next gathering with friends.
0/1
There’s music inside!
Your Arduino can do much more than "just" make LEDs shine at different brightness levels. For example, it can make music. In the following lesson, you'll learn how to use a piezo buzzer and coax some charming tones out of it.
0/3
A Theremin with Ultrasound
Do you want to make a bit more music? In this lesson, you'll build a theremin that you operate with your HC-SR04 ultrasonic sensor. You move your hand toward and away from the sensor - your Arduino calculates the pitch of the tones from the distance, which are then played through your piezo buzzer.
0/5
The Sound Sensor
Ready to explore how your Arduino can respond to sounds? In this lesson, we'll connect a sound sensor to your Arduino and learn how to make it respond to both digital noise detection and analog volume levels.
0/1
Build an Alarm System
In this project, you will build your own alarm system. It consists of three components: the sound sensor, which you have just learned about, the active piezo buzzer, and the RGB LED.
0/2
The DHT11 Temperature Sensor
Let's move on to another component that you'll certainly use in many projects: the temperature sensor. In this case, the popular DHT11, which can measure not only temperature but also humidity.
0/3
Arduino Course for Beginners

Time for some music! In this lesson, you’ll use your potentiometer and the piezo buzzer to create continuously variable tones within a specific range.

Once again, you’ll use the map() function that you already know. Additionally, you’ll use another new function: tone()

What are Tones?

First, we need to take a quick look at what tones actually are. In principle, they are vibrations with a specific frequency. More precisely, they are pressure fluctuations whose speed produces different pitches.

The higher the frequency of the fluctuations, the higher the tone. If you have a landline telephone, you can listen to the dial tone. This is often the so-called concert pitch A, which sounds at a frequency of 440 Hertz (Hz).

To produce an A one octave lower, you need to create a vibration that is half as large: 220 Hz. All other notes in the scale also have fixed frequencies. You can view a fairly extensive list of notes and corresponding frequencies on Github.

Generating Tones

As briefly mentioned at the beginning, there’s a practical function that can generate tones with your piezo: tone()

___STEADY_PAYWALL___

This function expects at least two parameters: the pin to which your piezo is connected and the frequency. An optional third parameter is the tone duration.

tone(piezoPin, frequency, duration);

 

So if you want to generate the concert pitch A with your piezo on pin 10 – without limiting the tone duration – the code looks like this:

tone(10, 440);

 

Pretty simple, right? However, you want a variable pitch that you determine using your potentiometer. Therefore, you first read the potentiometer signal and “map” it to a specific range.

potiValue = analogRead(potiPin);
piezoValue = map(potiValue, 0, 1023, 262, 523);

 

This time, this range is between 262 Hz and 523 Hz. These are the two C notes in two different octaves.

You then assign the frequency found with the map() function to the variable piezoValue. Then comes the tone() function:

tone(piezoPin, piezoValue);

 

Here, you output the frequency through the piezo buzzer on the pin piezoPin. However: While the tone range is limited by a low and a high C, the tones in between are “continuous,” which means they don’t necessarily correspond to a D, E, or F, etc.

Upload the sketch from the Exercise Files to your Arduino. Can you hear the tones and can you change them by turning the potentiometer? Sounds a bit like science fiction, doesn’t it? In the next lesson, you’ll build a kind of music box that plays a classic: Beethoven’s “Für Elise.”

Exercise Files
your_first_arduino_instrument.zip
Size: 1.43 KB
We don't track you. Enjoy your cookies while making awesome projects!