contact info:
info@blueink.com

Blueink.com
3014 Bluff #101
Boulder CO 80301

'the following is a midi example using the BX24 and the SFR04 proximity sensor.

dim outputBuffer(1 To 13) as byte
dim inputBuffer(1 To 10) as byte
dim output as byte
public Note as byte
dim distance as integer
dim pulsewidth as integer
Sub Main()

call flashme(10)

'open the input and output buffers:
call openQueue(outputBuffer, 13)
call openQueue(inputBuffer, 10)

call openCom(1, 9600, inputBuffer, outputBuffer)
register.ubrr = 14


do
'GET PROXIMITY VALUE
call pulseOut(14, 15.0, 1)
pulsewidth = pulseIn(13, 1)
Pulsewidth = pulsewidth \ 29

note = cbyte(pulsewidth)

if note < 120 then
call playnote()
end if


loop

End Sub

sub playnote()
call putpin(5, 1)


output = 144
call putQueue(outputBuffer, output, 1)
call putQueue(outputBuffer, note, 1)
output = 70
call putQueue(outputBuffer, output, 1)

call delay(0.5)
call stopnote()

end sub

sub stopnote()
call putpin(5, 0)


output = 144
call putQueue(outputBuffer, output, 1)
call putQueue(outputBuffer, note, 1)
output = 0
call putQueue(outputBuffer, output, 1)

end sub