|
If you cannot download
the examples above- I have included the code below.
'----------------------------------------------
'BX24 Serial to Director- Jen Lewin
'in
the below example, a photocell is wired to pin 13, and a potentiometer
'is wired to pin 19. This pot, is used tune the photocell range.
'The program sends
the photocell and pot values out to director.
'A number 1 is sent to initiate this sequence.
'The pot is used to 'tune' the range of the photocell- depending on the
'existing lighting conditions (this is a nice way to 'tune' your sensors
'on the fly, without needing to reprogram.
dim outputBuffer(1 To 30) as byte
dim inputBuffer(1 To 30) as byte
'dim getlight as
integer
dim light as integer
dim tune as integer
dim color as byte
dim out as byte
dim serialOUTpin as byte
dim serialINpin 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)
do
tune = getADC(19) \ 4 '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.
out = 1 'director knows to start sequence when 1 is recieved.
call putQueue(outputBuffer, out, 1)' tell director to GET READY
call putQueue(outputBuffer, light, 1) 'send LIGHT value (photocell)
call putQueue(outputBuffer, tune, 1) 'send Tune value (pot)
loop
End Sub
|