November 21, 2024, 09:59:25 PM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


Paparazzi Program Help

Started by Spooky Dad, May 13, 2015, 02:49:53 PM

Previous topic - Next topic

Spooky Dad

I am looking for a program for a prop-1 that will simulate the camera flashes on all 8 outputs.  There is no input required, just when the program starts running the camera flashes (LEDs) start flashing.  It would be great if there was some randomness between flashes, randomness of which outputs are tripped (random order) and that all outputs would trip (based on our recent discussion) before any output could be re-tripped.  Thanks!

JonnyMac

This is a translation of a Propeller program I wrote for for the DEF CON 22 badge. If you have bright outputs it is really effective.

' =========================================================================
'
'   File...... paparazzi_flasher.bs1
'   Purpose...
'   Author.... JonnyMac
'   E-mail....
'   Started...
'   Updated... 13 MAR 2015
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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


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


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

SYMBOL  playlist        = B2                    ' list of "played" outputs
SYMBOL  idx             = B3                    ' current selection
SYMBOL  last            = B4                    ' last played output
SYMBOL  mask            = B5                    ' bit mask for idx
SYMBOL  check           = B6                    ' test var

SYMBOL  delay           = W4                    ' flash/off delay
SYMBOL  lottery         = W5                    ' random #


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

Start_Up:
  lottery = 513                                 ' seed randomizer

Reset:
  PINS = %00000000                              ' all off
  DIRS = %11111111                              ' all outputs

  playlist = %00000000


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

Main:
  RANDOM lottery                                ' stir random #
  idx = lottery & %111                          ' 0..7
  IF idx = last THEN Main                       ' if last, try again

  READ idx, mask                                ' convert idx to mask
  check = mask & playlist                       ' check if played
  IF check <> %00000000 THEN Main               ' if played, try again

  RANDOM lottery                                ' re-stir
  delay = lottery // 26 + 25                    ' delay, 25-50ms
  HIGH idx                                      ' flash
  PAUSE delay
  LOW idx

  RANDOM lottery                                ' re-stir
  delay = lottery // 226 + 25                   ' delay, 25-250ms
  PAUSE delay

  last = idx                                    ' mark last output
  playlist = playlist | mask                    ' add to play list
  IF playlist = %11111111 THEN Reset            ' if full, reset

  GOTO Main


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


' -----[ User Data ]-------------------------------------------------------

Bit_Masks:
  EEPROM($01, $02, $04, $08, $10, $20, $40, $80)
Jon McPhalen
EFX-TEK Hollywood Office

Spooky Dad

Thanks JonnyMac!  Continuously impressed on the simple elegance of your code.  I could never have the program be so compact.  Thank you!

Spooky Dad

JonnyMac - I loaded the program, but outputs 6 and 7 are not firing.  I confirmed that LEDs are working on 0 through 5 do not light up when on 6 or 7.  I have been staring at the code and for the life of me I can find the problem. 

Spooky Dad

Set up jumpers are removed (forgot to mention) and still not firing.

Spooky Dad

Found it.  The top two left pins on the ULN2803 (notch facing up) were cut.  I had a spare ULN2803, replaced it and all is working fine. 

JonnyMac

QuoteI have been staring at the code and for the life of me I can find the problem.


Funny how we're always so quick to blame the programmer....   ;)

Glad you found the [user-induced] hardware problem; I hope the program does what you want.
Jon McPhalen
EFX-TEK Hollywood Office