Sounds we hear are made by when air is made to vibrate back and forth at a particular frequency. The speakers in your computer are made to do just this, having a moveable diaphram that pushes on the air when an electrical signal is applied to them. If you want to make sounds as a programmer, all you need is the ability to send signals to your speakers. Here we introduce the sound function, that allows you to do just that--send a signal to your speakers, so you can make them play a sound of any given frequency.
Move the mouse over a dotted box for more information.
Now you try. Try putting in any frequency and duration you want, which can be a number from 100 to 10,000 or so.
Type your code here:
See your results here:
Remember, you are coding now, so you don't have to program in sounds one at a time. You can use a for-loop to make all kinds of interesting sequences, like this
for f=500,600,10 do
for f=100,5000,100 do
Show a friend, family member, or teacher what you've done!
Here is a share link to your code:
Does your code work? Want to run it on your iPhone?
Here's your code:
Use [Control]-[C] (Windows) or [⌘]-[C] (MacOS) to copy your code.
Paste it using [Control]-[V] (Windows) or [⌘]-[V] (MacOS) into
Then click the "Use on iPhone" button that you'll see.