Introduction: Model Railway Station Sounds

Add fun to your layout, through addition of station sounds of your own choosing from steam sounds, whistles, phone rings, disco music, train announcements, etc.

Most of the cheap IR receivers found online are too sensitive to surrounding light sources such as daylight and and electrical lighting. The TSO2138 use here has an in-built filter to cancel this noise giving a clean reception of IR coding.
The circuit includes an Arduino Pro Mini with IR input and an SD card module. We also have an audio amplifier chip TDA2822 with a volume control potentiometer and a 8 ohm, 0.5 watt, 2 inch diameter speaker.

Powered by the model railway DC voltage 12v/14v

The Arduino sketch is provided here plus some example sound files in .wav format.

Please refer to another Instructable on how to convert sound files for use on the Arduino SD card module.

Circuit diagrams are included above.

Arduino / sd card components:

4 off Ceramic 0.1uf (100 nF) £1 eBay

2 off Capacitor 100uf 25v £1.09 eBay

1 off Capacitor 470uf 25v 25 for £2.29 eBay

2 off 10 Ω Resistor 20 for £1 eBay

2 off Screw terminal - 2 pins (0.137 inch) 3.5mm; 2 for £1 eBay

1 off Voltage Regulator 7809; voltage 9V; package TO-220 £2 eBay

1 off 3 pins Female Header Edge Pins Strip 0.1" 2.54mm; 10 for £2.77 eBay

1 off Trimmer Potentiometer 10kΩ; 5 for £1.59 eBay

1 off 6 pins Female Header Edge Pins Strip 0.1" 2.54mm;10 for £2.84 eBay

1 off IC TDA2822 pins 8 DIL; £1.55 eBay

1 off mini 8 ohm speaker similar to: eBay

1 off Arduino compatible SD card module similar to: eBay

1 off micro sd 1 Gb memory card similar to: eBay

1 off IR transmitter (tv remote) similar to: eBay

IR receiver components :

1 off IR receiver TSOP2138 ; 5 for £3.67 eBay

1 off 100 Ω Resistor 30 for £1.89 eBay

1 off 10k Ω Resistor £1.29 for 10 eBay

1 off Capacitor 4.7uf 25v £1 eBay

1 off 3 pins Female Header Edge Pins Strip 0.1" 2.54mm; (See above from eBay)

Step 1: Printed Circuit Boards

These PCB's are no longer available on ebay. The circuit may be assembled on Vero board or similar.
The main PCB contains the Arduino Pro Mini module, SD micro card module, TDA amplifier and 9 volt regulator plus connectors, capacitors and resistors. A small PCB is also required to hold the IR receiver circuit.

Although the circuit diagram shows the use of sockets for the Arduino Pro Mini , it should be soldered directly onto the PCB to avoid overlapping the SD card module.

The system takes sound files in .wav format on the micro sd card through the TDA amplifier to the 8 ohm 0.5 watt mini speaker. Each sound file is selected via an IR receiver circuit from a mini IR remote transmitter.

The system may be built into a layout building such as a station, or mounted under the layout board. You will need to have the IR receiver within sight of the IR beam from the transmitter.

Step 2: Sound Files

Sound files - attached files are example of train sounds. You may record your own to suit the purpose.

Step 3: Arduino Pro Mini Code

Arduino Pro Mini code:

#include "SD.h"<br>#include "pcmRF.h"
#include "pcmConfig.h"
#include "TMRpcm.h"<br>#define SD_ChipSelectPin 10  //use digital pin 4 on arduino nano 328
TMRpcm tmrpcm;   // create an object for use in this sketch
#include "IRremote.h" <br>// Start the receiver<br>IRrecv irDetect(A2);  // Arduino A2 Pin for infrared sensor
decode_results irIn;  // define functions attached to IR remote input keys
#define Play1 16738455  //1 these are the codes for the IR transmitter used
#define Play2 16750695  //2
#define Play3 16756815  //3
#define Play4 16724175  //4
#define Play5 16718055  //5
#define Play6 16743045  //6
#define Play7 16716015  //7
#define light_1 16730805  //0
#define light_2 16728765  <br>boolean L1, L2;

void setup(){<br>Serial.begin(9600);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  
   Serial.println("... Initializing");
  tmrpcm.speakerPin = 9; //11 on Mega, 9 on Uno, Nano, etc
 
  if (!SD.begin(SD_ChipSelectPin)) {  <br>// see if the card is present and can be initialized:
    Serial.println("... Initializing");
  return;   <br>// don't do anything more if not
  }
  Serial.println("... done");
 tmrpcm.setVolume(4);
 tmrpcm.play("station2.wav"); <br>//the sound file "1" will play each time the arduino powers up, or is reset
 delay (2000);
 
// Start the receiver
irDetect.enableIRIn(); 
Serial.println("Finished setup - Waiting for Key Press");
}
 void loop(){
if (irDetect.decode(&irIn)) {
    Serial.println("Translating..... Please Wait....."); 
    translateIR();
    Serial.println(irIn.value,DEC);
    delay(200);
    irDetect.resume(); <br>// Receive the next value  
  } 
}<br>void translateIR() <br>// takes action based on IR code received<br>{
  switch(irIn.value)
  {
    case Play1: play1(); break;
    case Play2: play2(); break;
    case Play3: play3(); break;
    case Play4: play4(); break;
    case Play5: play5(); break;
    case Play6: play6(); break;
    case Play7: play7(); break;
    case light_1: light1(); break;
    case light_2: light2(); break;
    
    default: Serial.println("Key not configured");
  }
 delay(200);
  }
void light1(){
  L1 ^= 1;
digitalWrite(3, L1);
Serial.println(L1);
      }     
void light2(){
  L2 ^= 1;
digitalWrite(4, L2);
Serial.println(L2);
      }       
 void play1(){
      tmrpcm.play("noah2.wav");
      Serial.println("... playing 1");
       delay (2000);
 }<br>void play2(){
      tmrpcm.play("station1.wav");
      Serial.println("... playing 2");
       delay (2000);
 }
 void play3(){
      tmrpcm.play("station2.wav");
      Serial.println("... playing 3");
       delay (2000);
 }
 void play4(){
      tmrpcm.play("phone.wav");
      Serial.println("... playing 4");
       delay (2000);
 }
 void play5(){
      tmrpcm.play("whistle.wav");
      Serial.println("... playing 5");
       delay (2000);
 }
 void play6(){
      tmrpcm.play("train.wav");
      Serial.println("... playing 6");
       delay (2000);
 }
void play7(){
      tmrpcm.play("train2.wav");
      Serial.println("... playing 6");
       delay (2000);
 }