Help with Animation

dpoquette Apr 25, 2024

  1. dpoquette

    dpoquette New Member

    5
    3
    10
    I have a question that I hope somebody will be able to help me with.

    I’m looking into using Arduino’s to play sound in my layout. For example when a steam loco stops over the cinder pit, I would like the sound of the fire doors open (I have a sound file), then turn on an LED in the pit for 1 min.

    I’m sure I can get this to work. The key is a 5-10 sec delay in the occupancy detector before it sends a signal to the Arduino.

    I know I have to get a track occupancy detector. RR-Cir has an 8 block occupancy detector. Does anybody know what else I would need to connect this to an Arduino? I also know I would need a sound player as well.

    Using the same cinder pit example. If I have 3 cinder pits, do I need 3 arduinos or can I use one for 3 pits?


    Sent from my iPhone using Tapatalk
     
  2. Sumner

    Sumner TrainBoard Member

    2,849
    6,018
    63
    You could probably google for some sketches on using sound. Do you have any experience coding an Arduino? I'm into it again and constantly have to look for examples of what I want to do and then plug away at it trying to incorporate them into my code.

    The 5-10 second delay is easy. Don't delay the occupancy detector. Let it signal the Arduino and then use the delay() command for the Arduino to put the delay in at that point.

    Good luck and happy learning,

    Sumner
     
  3. GGNInNScale

    GGNInNScale TrainBoard Member

    244
    699
    10
    You can program this pretty easily. You will need a small amplifier and speaker, of course. I use Azatrax shield sensors to trigger lights and signals using 5V power relays and IXYS opto-coupled relays. You drive the IXYS solid state relays (SSRs) with the Arduino, which can control up to about 250mAmps (they say 350 but this will be really hot!). Then, use the IXYS relays to switch 5V source power relays to run everything else. This method keeps the Arduino from having to source a lot of current. I would not recommend using the Arduino power source for the LEDs or sound, as it can only supply 50mA max. You can do all of your circuits and sound with one UNO or MEGA (the MEGA would be a serious overkill, but it is only a few bucks more). You can put in time delays in the Arduino code- DO NOT use a looping timer delay() as it stops the program while it is waiting for the time counter to expire. Use millis() or micros() to make delays. See the Arduino site for lots of tips. I did check on the pricing of the SSRs at DigiKey, that have increased a lot in the past 18 months, but still pretty cheap. Very reliable parts, too.
     
    Last edited: Apr 25, 2024
  4. dpoquette

    dpoquette New Member

    5
    3
    10
    Thanks. I’ll look into it further. While my background is in computer programming, I have not programmed an Arduino but I’m sure it’s not that difficult.



    Dave P
     
    Last edited: Apr 25, 2024
  5. GGNInNScale

    GGNInNScale TrainBoard Member

    244
    699
    10
    Hi Programming is kind of like the C language family. There are some special characters that you have to keep track of, but it is pretty simple. Add a lot of comments- makes things easier, and takes no space.
     

Share This Page