'Serial comm example for MedeaWiz DV-68 digital video player using 'Parallax Basic Stamp model BS2 'This program allows use of 4 pushbuttons to select 1 of 4 video files to 'play and turns on 1 of 4 relays corresponding to the video file as long 'as the file is playing. Tested with 5 video files on flash card, 000.mpg '(attract loop) and 001.mpg through 004.mpg '02/05/07 Team Kingsley LLC 'www.teamkingsley.com '{$STAMP BS2} ' {$PBASIC 2.5} '188 on BS2 = 4800 baud rec VAR Byte(18) 'var to hold incomming data from the DV-68 track VAR Byte 'register for current video file relay VAR Nib 'register for current relay output time VAR Byte index VAR Byte 'iteration register DIRA = %0000 'sets I/O 0,1,2,3 to inputs for buttons DIRC = %1111 'sets I/O 8,9,10,11 to outputs for relays OUTC = %0000 'all ouputs off PAUSE 7000 'allow DV-68 time to boot when powered on Top: IF IN0 = 0 THEN 'using I/O 0 for button 1, tied high w/ 10K R track = 1 'to play video file 001.mpg relay = 8 'I/O 8 for relay ELSEIF IN1 = 0 THEN 'using I/O 1 for button 2, tied high w/ 10K R track = 2 'to play video file 002.mpg relay = 9 'I/O 9 for relay ELSEIF IN2 = 0 THEN 'using I/O 2 for button 3, tied high w/ 10K R track = 3 'to play video file 003.mpg relay = 10 'I/O 10 for relay ELSEIF IN3 = 0 THEN 'using I/O 3 for button 4, tied high w/ 10K R track = 4 'to play video file 004.mpg relay = 11 'I/O 11 for relay ELSE GOTO top 'if button not pressed, go check again ENDIF SEROUT 15, 188, [track] 'play track [x] PAUSE 300 'pause miliseconds to allow file to start before relay on HIGH relay 'turn on (relay) SEROUT 15, 188, [232]'ask DV-68 for status on I/O 14 (returns 18 bytes) SERIN 14, 188, [STR rec\18] 'retrieve data from DV-68 on I/O 15 FOR index = 0 TO 17 DEBUG HEX? rec(index) 'show raw hex data on Debug screen NEXT track = rec(16) - $31 'track read from DV-68 minus offset 'this code only works up to track 9 since we are not checking 'the other bytes of track data DEBUG "Track ", DEC track, CR PAUSE 1000 'this pause is to insure the file has started playing 'and we don't read the EOF marker from previous file timeloop: 'searching for the EOF (end of file) Marker 'DV-68 sends time (1st 6) and status (2nd 6 bytes) every second SERIN 14, 188, [STR rec\12] FOR index = 0 TO 11 DEBUG HEX rec(index) 'show raw hex data on Debug screen NEXT DEBUG CR, CR 'the 4 bytes below indicate DV-68 is at the end of the video file IF rec(0) = $30 AND rec(1)= $31 AND rec(3) = $30 AND rec(4)= $31 THEN Eof GOTO timeloop Eof: DEBUG "End of file found" OUTC = %0000 'all ouputs off 'turn off (relay) PAUSE 2000 'hold time before allowing another button press/ file change GOTO top 'go to top and do it all again END 'As in anytime I write code, there is usually a more efficient code to do the 'job. We are always open to suggestions and other points of view. If you have 'any, or have other code you wish to share for the DV-68, please send it to 'bill@teamkingsley.com and we will post it on the website to help others.