Option Explicit Private Const InputBufferSize As Integer = 64 ' Input queue Private Const OutputBufferSize As Integer = 64 ' Output queue Private InputBuffer(1 To InputBufferSize) As Byte Private OutputBuffer(1 To OutputBufferSize) As Byte const inPin as Byte = 15 'Pin used as input for the serial dim EyesCount as integer dim MouthCount as integer dim HeartCount as integer dim StomachCount as integer dim IntimateCount as integer dim HandsCount as integer dim LegsCount as integer Public Sub Main() '_____________________ Dim inbyte as Byte Dim ThisByte as Byte Dim PrevByte as Byte Dim TestByte as Byte Call OpenSerialPort( 3, 19200 ) die: 'restart program EyesCount = 0 MouthCount = 0 HeartCount = 0 StomachCount = 0 IntimateCount = 0 HandsCount = 0 LegsCount = 0 call InitPrint() prevbyte=0 Do PrevByte = ThisByte 'put the last byte into prevbyte call getbyte(inbyte) 'get the current byte ''debug.print "hello " & cstr(inbyte) ThisByte = inbyte 'put the current byte into thisbyte if (ThisByte <> PrevByte) then 'only if there was a change going UP from 0 to a number if (ThisByte <> 0) then delay(0.05) call getbyte(inbyte) 'get the current byte NOW TestByte = inbyte if (TestByte = ThisByte) then 'only if it's stable in 50 ms Select Case inbyte Case 1 'eyes = 1 EyesCount = EyesCount + 1 call freqout(20,5000,6040,100) call freqout(20,3000,3299,75) call freqout(20,5000,6040,400) call LineDown() Case 35 'mouth = 35 MouthCount = MouthCount + 1 call freqout(20,500,604, 3000) call freqout(20,3000,3299,80) call freqout(20,6000,7000,40) call LineDown() Case 70 'heart = 70 HeartCount = HeartCount + 1 call freqout(20,1400,604, 500) call freqout(20,599,7000,40) call LineDown() Case 105 'stomach = 105 StomachCount = StomachCount + 1 call freqout(20,6400,7774, 500) 'eye call LineDown() Case 140 'intimate = 140 IntimateCount = IntimateCount + 1 call freqout(20,7800,10774, 500) 'eye call LineDown() Case 175 'legs = 175 LegsCount = LegsCount + 1 call freqout(20,1000,604, 300) call freqout(20,9000,7000,70) call LineDown() Case 210 'hands = 210 HandsCount = HandsCount + 1 call freqout(20,900,700,450) call LineDown() Case 245 'needle cushion = 24 call PrintBill() goto die 'Exit Sub End Select End if ' TestByte = ThisByte End if ' ThisByte <> 0 End if ' ThisByte <> PrevByte Loop End Sub Public Sub OpenSerialPort(ByVal PortNumber As Byte, ByVal BaudRate As Long) '_____________________ Dim inputpinNumber as Byte inputpinNumber = inPin call DefineCom3(inputpinNumber, 0, bx0000_1000) 'the pin used for input is the 8 (you can change it to whatever pin you want to read from) Call OpenQueue(InputBuffer, InputBufferSize) Call OpenQueue(OutputBuffer, OutputBufferSize) Call OpenCom(PortNumber, BaudRate, InputBuffer, OutputBuffer) End Sub Public Sub GetByte(ByRef Value As Byte) If (StatusQueue(InputBuffer)) Then Call GetQueue(InputBuffer, Value, 1) ' else ' Value = 0 End If End Sub Public Sub PrintBill() '_____________________ dim Eyes as integer dim Mouth as integer dim Heart as integer dim Stomach as integer dim Intimate as integer dim Hands as integer dim Legs as integer Eyes = EyesCount + 48 Mouth = MouthCount + 48 Heart = HeartCount + 48 Stomach = StomachCount + 48 Intimate = IntimateCount + 48 Hands = HandsCount + 48 Legs = LegsCount + 48 ''debug.print "printing..." call InitPrint() delay(0.5) '''''try call PrintChar("E") call PrintChar("Y") call PrintChar("E") call PrintChar("S") call PrintChar(":") call PrintChar(" ") call PrintChar(Chr(Eyes)) call LineDown() call PrintChar("M") call PrintChar("O") call PrintChar("U") call PrintChar("T") call PrintChar("H") call PrintChar(":") call PrintChar(" ") call PrintChar(Chr(Mouth)) call LineDown() call PrintChar("H") call PrintChar("E") call PrintChar("A") call PrintChar("R") call PrintChar("T") call PrintChar(":") call PrintChar(" ") call PrintChar(Chr(Heart)) call LineDown() call PrintChar("S") call PrintChar("T") call PrintChar("O") call PrintChar("M") call PrintChar("A") call PrintChar("C") call PrintChar("H") call PrintChar(":") call PrintChar(" ") call PrintChar(Chr(Stomach)) call LineDown() call PrintChar("I") call PrintChar("N") call PrintChar("T") call PrintChar("I") call PrintChar("M") call PrintChar("A") call PrintChar("T") call PrintChar("E") call PrintChar(":") call PrintChar(" ") call PrintChar(Chr(Intimate)) call LineDown() call PrintChar("L") call PrintChar("E") call PrintChar("G") call PrintChar("S") call PrintChar(":") call PrintChar(" ") call PrintChar(Chr(Legs)) call LineDown() call PrintChar("H") call PrintChar("A") call PrintChar("N") call PrintChar("D") call PrintChar("S") call PrintChar(":") call PrintChar(" ") call PrintChar(Chr(Hands)) call LineDown() call LineDown() call PrintChar("Y") call PrintChar("O") call PrintChar("U") call PrintChar("R") call PrintChar(" ") call PrintChar("T") call PrintChar("O") call PrintChar("T") call PrintChar("A") call PrintChar("L") call PrintChar(" ") call PrintChar(":") call LineDown() call PrintChar("4") call PrintChar("9") call PrintChar(",") call PrintChar("9") call PrintChar("9") call PrintChar("$") call LineDown() call LineDown() call PrintChar("T") call PrintChar("H") call PrintChar("A") call PrintChar("N") call PrintChar("K") call PrintChar(" ") call PrintChar("Y") call PrintChar("O") call PrintChar("U") call PrintChar(" ") call PrintChar("F") call PrintChar("O") call PrintChar("R") call PrintChar(" ") call PrintChar("U") call PrintChar("S") call PrintChar("I") call PrintChar("N") call PrintChar("G") call LineDown() call PrintChar("V") call PrintChar("O") call PrintChar("O") call PrintChar("B") call PrintChar("O") call PrintChar("X") call PrintChar("!") call LineDown() End Sub public sub PrintChar(byVal CHAR as string) '_____________________ call PutPin(16,1) 'sets the "pulse" pin on the printer (no. 16) to be ON; we should connect BX pin16 to PRINTER pin16 register.PORTC = asc(CHAR) call PulseOut(16, 0.0001, 0) 'call delay(0.1) do loop until (getPin(17)=0) 'call PutPin(16,1) 'sets the "pulse" pin on the printer (no. 16) to be ON; we should connect BX pin16 to PRINTER pin16 end sub public sub InitPrint() '_____________________ register.DDRC = bx1111_1111 call PulseOut(14, 0.001, 0) ' printer reset pin is 14 CALL DELAY (0.05) call PutPin(16,1) register.PORTC = 11 'VT call PulseOut(16, 0.0001, 0) call delay(0.05) end sub public sub LineDown() '_____________________ call printchar(chr(11)) call printchar(chr(13)) end sub