dim inputBuffer(1 To 13) As Byte dim outputBuffer(1 To 10) As Byte dim status as byte dim controller1 as byte dim controller2 as byte dim controller3 as byte dim controller4 as byte dim controller5 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 call 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) controller1 = 1 controller2 = 2 controller3 = 3 controller4 = 4 controller5 = 5 switch1 = 10 switch2 = 20 switch3 = 30 status = 176 'controller #1 call putQueue(OutputBuffer, status, 1) call putQueue(OutputBuffer, controller1, 1) call putQueue(OutputBuffer, flexSensor1, 1) call delay(0.2) 'controller #2 call putQueue(OutputBuffer, status, 1) call putQueue(OutputBuffer, controller2, 1) call putQueue(OutputBuffer, flexSensor2, 1) call delay(0.2) if getPin(5) = 1 then switch1 = 11 'debug.print "switch1 is now on" ; cstr(switch1) 'controller #3 call putQueue(OutputBuffer, status, 1) call putQueue(OutputBuffer, controller3, 1) call putQueue(OutputBuffer, switch1, 1) call delay(0.2) else switch1 = 10 'debug.print "switch1 is now off" ; cstr(switch1) 'controller #3 call putQueue(OutputBuffer, status, 1) call putQueue(OutputBuffer, controller3, 1) call putQueue(OutputBuffer, switch1, 1) call delay(0.2) end if if getPin(7) = 1 then switch2 = 21 'debug.print "switch2 is now on" ; cstr(switch2) 'controller #4 call putQueue(OutputBuffer, status, 1) call putQueue(OutputBuffer, controller4, 1) call putQueue(OutputBuffer, switch2, 1) call delay(0.2) else switch2 = 20 'debug.print "switch2 is now off" ; cstr(switch2) 'controller #4 call putQueue(OutputBuffer, status, 1) call putQueue(OutputBuffer, controller4, 1) call putQueue(OutputBuffer, switch2, 1) call delay(0.2) end if if getPin(9) = 1 then switch3 = 31 'debug.print "switch3 is now on" ; cstr(switch3) 'controller #5 call putQueue(OutputBuffer, status, 1) call putQueue(OutputBuffer, controller5, 1) call putQueue(OutputBuffer, switch3, 1) call delay(0.2) else switch3 = 30 'debug.print "switch3 is now off" ; cstr(switch3) 'controller #5 call putQueue(OutputBuffer, status, 1) call putQueue(OutputBuffer, controller5, 1) call putQueue(OutputBuffer, switch3, 1) call delay(0.2) end if loop end sub