November 26, 2024, 04:46:13 AM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


MP3_4x.BS1: Prop-1 connection to mp3 players

Started by peroberts, October 25, 2008, 12:42:49 AM

Previous topic - Next topic

peroberts

This was a program Jon wrote to trigger (4) mp3 players with the Prop-1. Can someone show me how the mp3 players are connected to the Prop-1? I currently have a relay connected to the "play" buttons on each of the mp3 players, that I have just been triggering manually.

JonnyMac

October 25, 2008, 10:23:08 AM #1 Last Edit: October 25, 2008, 11:30:17 AM by JonnyMac
Use one relay for each MP3 player (four total); one side of the relay connects to V+, the other side to the OUTx terminal of your choice (again, one per relay).  When you make the corresponding IO pin HIGH the relay will activate which simulates pressing Play.  If you describe how you want your program to work I'll write it for you.
Jon McPhalen
EFX-TEK Hollywood Office

peroberts

I would like the first mp3 player to play, triggered by a motion sensor (the Parallax PIR). When it finishes, I would like the second to play, and when it finishes, the third mp3 player etc, through all 4 players. The motion sensor would not trigger again until after the fourth player had finished.

JonnyMac

October 25, 2008, 11:14:46 AM #3 Last Edit: October 25, 2008, 12:49:29 PM by JonnyMac
How long does each player play? 

Here's a program where I've arbitrarily set each player for five seconds -- once you have your MP3 players setup you'll need to adjust the timing for each.

' =========================================================================
'
'   File...... MP3x4.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2008 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 25 OCT 2008
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Trigger         = PIN6                  ' SETUP = DN  (PIR)

SYMBOL  Play4           = PIN3                  ' use V+/OUT3
SYMBOL  Play3           = PIN2                  ' use V+/OUT2
SYMBOL  Play2           = PIN1                  ' use V+/OUT1
SYMBOL  Play1           = PIN0                  ' use V+/OUT0


' -----[ Constants ]-------------------------------------------------------

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0

SYMBOL  Yes             = 1
SYMBOL  No              = 0


' -----[ Variables ]-------------------------------------------------------

SYMBOL  timer           = W1


' -----[ Initialization ]--------------------------------------------------

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00001111                              ' set outputs


' -----[ Program Code ]----------------------------------------------------

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

Player_1:
  Play1 = IsOn                                  ' "press" play button
  PAUSE 500
  Play1 = IsOff
  timer = 253                                   ' 4:13 ((4 x 60) + 13)
  GOSUB Delay_Secs

Player_2:
  Play2 = IsOn
  PAUSE 500
  Play2 = IsOff
  timer = 10                                    ' 0:10
  GOSUB Delay_Secs

Player_3:
  Play3 = IsOn
  PAUSE 500
  Play3 = IsOff
  timer = 23                                    ' 0:23
  GOSUB Delay_Secs

Player_4:
  Play4 = IsOn
  PAUSE 500
  Play4 = IsOff
  timer = 165                                   ' 2:45 ((2 x 60) + 45)
  GOSUB Delay_Secs

  GOTO Main


' -----[ Subroutines ]-----------------------------------------------------

Delay_Secs:
  IF timer = 0 THEN Delay_Exit
    PAUSE 1000
    timer = timer - 1
    GOTO Delay_Secs

Delay_Exit:
  RETURN


' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

peroberts

Player #1 = 4:13
Player #2 = 0:10
Player #3 = 0:23
Player #4 = 2:45

Thanks you so much for your help.  This is a great learning experience.

JonnyMac

I've updated your program with a subroutine to handle the long delays.
Jon McPhalen
EFX-TEK Hollywood Office

peroberts