|
Serial Communication and Director STUFF I LEARNED '---------------------------------------------- 'BX24 Serial to Director- my variation on Jen's code dim outputBuffer(1 To 30) as byte dim inputBuffer(1 To 30) as byte 'dim getlight as integer dim photo1 as integer dim photo2 as integer dim color as byte dim out as byte dim serialOUTpin as byte dim serialINpin as byte dim buzzer as byte sub main() serialOUTpin = 12 serialINpin = 11 ' open the input and output buffers: call openQueue(outputBuffer, 30) call openQueue(inputBuffer, 30) ' define which pins we'll use for serial in and out: call defineCom3(serialINpin, serialOUTpin, bx1000_1000) call openCom(3, 9600, inputBuffer, outputBuffer) call putQueueStr(outputBuffer, chr(12)) 'clears the screen do tune = getADC(19) \ 5 + 2 'a range of 0 to 255- must be a byte light = getADC(13) \ 4 + 2 'a range is 0 - 255 - must be a byte 'I add 2 here to make sure that I never recieve anything close to a 1 value 'as I need 1 to send to director to start my sequence. photo1String = cstr(photo1) photo2String = cstr(photo2) 'call putQueueStr(outputBuffer, photo1String) 'call putQueueStr(outputBuffer, chr(10) & chr(13)) 'call putQueueStr(outputBuffer, photo2String) 'call putQueueStr(outputBuffer, chr(10) & chr(13)) out = 1 'director knows to start sequence when 1 is recieved. call putQueue(outputBuffer, out, 1)' tell director to GET READY call putQueue(outputBuffer, photo1, 1) 'send LIGHT value (photocell) call putQueue(outputBuffer, photo2, 1) 'send Tune value (pot) call getQueue(inputBuffer, buzzer, 1) 'receive data from director if (buzzer = 255) then call putPin(15, 1) else call putPin(15, 0) end if loop End Sub DIRECTOR MOVIE
|
||