dim inputBuffer(1 To 13) As Byte dim outputBuffer(1 To 10) As Byte dim controller1 as byte dim controller2 as byte dim controller3 as byte dim controller4 as byte dim controller5 as byte dim channel as byte Sub main() call delay(0.5) ' start program with a half-second delay call putPin(13,1) ' so i know BX-24 is working, light up an LED delay(0.5) call putPin(13,0) dim flexSensor1 as byte dim flexSensor2 as byte dim switch1 as byte dim switch2 as byte dim switch3 as byte ' set up serial buffers: call openQueue(inputBuffer, 13) call openQueue(outputBuffer, 10) ' open serial port on COM1: call openCom(1, 9600, inputBuffer, outputBuffer) ' set baud rate to 30,270: register.ubrr = 14 do ' get a control range ' using a 10K variable resistor as input ' on pins 14 and 16: flexSensor1 = cByte(getADC(14)\4) flexSensor2 = cByte(getADC(16)\4) 'debug.print "flexSensor1 = " ; cstr(getADC(14)\4) 'debug.print "flexSensor2 = " ; cstr(getADC(16)\4) switch1 = 10 switch2 = 20 switch3 = 30 channel = 1 controller1 = 176 'controller #1 call putQueue(OutputBuffer, controller1, 1) call putQueue(OutputBuffer, flexSensor1, 1) call putQueue(OutputBuffer, channel, 1) call delay(0.2) controller2 = 177 'controller #2 'channel = 1 call putQueue(OutputBuffer, controller2, 1) call putQueue(OutputBuffer, flexSensor2, 1) call putQueue(OutputBuffer, channel, 1) call delay(0.2) if getPin(5) = 1 then ' debug.print "switch1 is now on" switch1 = switch1 + 1 if switch1 = 11 then controller3 = 178 'controller #3 call putQueue(OutputBuffer, controller3, 1) call putQueue(OutputBuffer, switch1, 1) call putQueue(OutputBuffer, channel, 1) call delay(0.2) switch1 = 10 end if end if if getPin(7) = 1 then ' debug.print "switch2 is now on" switch2 = switch2 + 1 if switch2 = 21 then controller4 = 179 'controller #4 call putQueue(OutputBuffer, controller4, 1) call putQueue(OutputBuffer, switch2, 1) call putQueue(OutputBuffer, channel, 1) call delay(0.2) switch2 = 20 end if end if if getPin(9) = 1 then ' debug.print "switch3 is now on" switch3 = switch3 + 1 if switch3 = 31 then controller5 = 180 'controller #5 call putQueue(OutputBuffer, controller5, 1) call putQueue(OutputBuffer, switch3, 1) call putQueue(OutputBuffer, channel, 1) call delay(0.2) switch3 = 30 end if end if loop end sub