May 02, 2024, 07:12:18 PM

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.


Random Servo and LED

Started by uncle, March 17, 2010, 12:30:55 PM

Previous topic - Next topic

uncle

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

SYMBOL  RX              = 7                           ' SETUP = UP, no ULN
SYMBOL  TX              = 6                           ' SETUP = UP, no ULN
SYMBOL  MatSw           = PIN5                        ' active-high input


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

SYMBOL  IsOn            = 1                           ' button pressed for active-high
                                                                  ' in/out
SYMBOL  IsOff           = 0                            ' button released
SYMBOL  LEDTime     = 150                         ' light-on delay time
SYMBOL  Baud            = OT2400


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

SYMBOL  thePin          = B2                          ' pin pointer

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

PAUSE 5000                                            'allow VMusic2 to initialize
SEROUT TX,Baud, ("VST",13)                            'stop anything that's playing
SEROUT TX,Baud, ("VSV 0",13)                          'Set volume to full
PAUSE 500                                             '.5 second delay



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

Strobe:
  FOR thePin = 0 TO 5                                 ' loop through LEDs
    HIGH thePin                                       ' LED on
    PAUSE LEDTime                                     ' hold on for designated time
    LOW thePin                                        ' LED off
  NEXT

Reset:                                                'Note: pin reset appears vital
PINS = %00000000                                      ' clear all
DIRS = %00011111                                      ' set 0-7 as outputs

Main:
IF MatSw = IsOff THEN Strobe                            'wait for "victim"
PAUSE 300                                             '.3 second delay

PINS = %00000000                                      ' clear all
DIRS = %00011111                                      ' set 0-7 as outputs

SEROUT TX,Baud,("VPF letout03.mp3",13)                'Play file named "g_host2.mp3"
PAUSE 3000                                            '30 second delay


GOTO Reset


Jon-

This program has the Prop-1 run the LED's, then activate the VMusic, and then activate the LED's again while the VMusic is still running.



JonnyMac

QuoteThis program has the Prop-1 run the LED's, then activate the VMusic, and then activate the LED's again while the VMusic is still running.

This is not terribly helpful information

The code, as is, will likely miss the remote command from your Prop-SX if it is in the middle of the Strobe cycle.  So... just tell me -- WITH HORRENDOUSLY GORY DETAIL  ;D -- what you want the Prop-1 to do.  I will re-craft it so that it can catch the short command pulse from the SX.  Please, define "activate the LEDs" (there is no ACTIVATE command in PBASIC <wink>).
Jon McPhalen
EFX-TEK Hollywood Office

uncle

The Prop-1 is supposed to loop through the 5 LED's (4 Led's blinking in a rotating pattern, and 1 meter needle jumping in conjunction with that pattern) while waiting for a signal to activate the VMusic. 

The signal activates the VMusic to play a file,and then WHILE the VMusic is still playing that file, the Prop-1 goes back to looping the LED's and meter. 

I know it is a messy program, but I had trouble getting it to re-start the LED/Meter pattern while the VMusic was still playing. The way it is now, there is still a hiccup in the running of the LED/meter pattern but it does run while the VMusic is still playing.

uncle

Ideally, while waiting for a signal from a mat switch, the Prop-SX is calmly powering the Cylon LED's back and forth, while the Prop-1 is powering 4 Led's in a rotating pattern, and is also powering 1 analog meter needle (fluctuating in conjunction with that pattern).

Upon receiving a signal from the mat, the Prop-SX starts flashing the Cylon LED's in a random pattern and activating the 2 servos in a random pattern.  The Prop-1, in conjunction with the random SX program, is supposed to play an audio vile on the VMusic WHILE still powering the LED's and analog meter.

The Prop-SX program is working great, the Prop-1 program is basically working, but I have been unable to get the Prop-1 to activate by signal from the SX.  Would it work better if we reversed things so the switch activated the Prop-1, which then sends a signal to the SX?

JackMan

As Jon mentioned, the problem is in your code. The Prop-1 is likely to be in the Strobe Loop when it gets the signal from the SX which would do nothing at that point.