Can you create a sound file in Ardunio?

I am working on a Model Railroad. I would like to create the sound of a Saw Mill controlled by a push button. Can you create a sound file for ardunio which can then be connected to a sound bar? I am new at Ardunio so please keep your answer simple.
Thanks in Advance
Harold

With a standalone small Arduino, probably not. But you can get an MP3 shield that will do it and control it from the Arduino.

The best way to play an audio file is with an audio shield (add-on board). You have to create/copy the file(s) in advance on your computer.

Some audio shields can directly drive a speaker but most require an amplifier. And, some have a very simple interface and they'll work without an Arduino. T(he one I linked to needs the Arduino,)

As I’m guessing it’s a fairly simple sound , then it may well be possible .
If you google “deisel engine Arduino” you might find something

Well, a short while ago you used to be able to make even a very basic micro speak real words by using the SP0256AL2;

I did build a card for an AppleII+ at the time using the SP0256AL2, great fun it was too.

There were also sound synthesizer chips in use, all the video games of course and these were mainly 8 bit bus based devices.

This was in the early 1980s, I wonder if similar chips are still available ?

The PCM library will allow you to play audio using only a basic Arduino (UNO, Nano, Mini...). Install it from "Tools->Manage Libraries..." in the IDE.

The tutorial tells you how to encode your own audio sample:

For samples longer than about 4 seconds, you will need either more FLASH memory (like an Arduino Mega) or a way to store audio on an SD card, like the "TMRpcm" library. Install it from "Tools->Manage Libraries..." in the IDE.

Tutorial here:
https://circuitdigest.com/microcontroller-projects/arduino-audio-music-player

You can get simple recorder boards on eBay - just record a sound on one of those and play it back

srnet:
Well, a short while ago you used to be able to make even a very basic micro speak real words by using the SP0256AL2;

General Instrument SP0256 - Wikipedia

I did build a card for an AppleII+ at the time using the SP0256AL2, great fun it was too.

There were also sound synthesizer chips in use, all the video games of course and these were mainly 8 bit bus based devices.

This was in the early 1980s, I wonder if similar chips are still available ?

I had a an apple ][ card back in the early 80's that was literally just a few transistors, nothing else.
The software bit-banged very ineligible natural sounding speech. MUCH better than the output from an SP0256.
You could control the pitch and the rate of the speech.
It even could do text to speech.

These days there are options for arduino boards like this:
https://www.pjrc.com/teensy/td_libs_Audio.html
and on esp32 you don't need any sort of shield. Just an amplifier:

I built this speaking clock about 2 years ago. It is based on an ESP8266 and the voice files are held in its file system (*SPIFFS) so there is no SD card. It is not really a beginners project, but there may be some things you can use from it.
https://forum.arduino.cc/index.php?topic=559652.0

  • now use LittleFS

Here is a sample project that demonstrates how to get text to speech on a esp8266/ESP32 using the old "SAM" methodology/code.

Which uses the ESP8266Audio library (which can be used to play several different types of audio files:

And here is a project that uses it for sounds for a model train:

--- bill