📄 irsertst.bas
字号:
' Title IRSerTst.Bas
' @ L. Johnson 20th September 1999
'
' Send Asyncronous Serial Data over an Infra-Red Link
' At Various Baud Rates and Inverted Mode
' An Infra-Red LED should be Connected to PORTB.0
' If longer range is required and NPN transistor could be employed
' as an amplifier, as in the BASIC STAMP1 Application Notes
'
' Place Include "Irserout.Bas"
' At the front of the Program to load the new subroutine in
'
' To Use the New Routine, Load the Variable:-
' IR_ByteOut with the appropriate value (0-255)
' And Call the Subroutine:-
' Gosub IRSerout
'
' Three New Defines have been added:-
' IRSEROUT_PORT.....Selects the Port for sending (ie PORTB)
' IRSEROUT_PIN......Selects the Pin for sending (ie 1)
' IRSEROUT_BAUD.....Selects the Baud Rate (ie 300,600,1200,2400)
' IRSerout works with 4Mhz, 8Mhz, 10Mhz and 12Mhz Xtals
' This routine is for the 16F84, but any 14bit core PIC could be used
Include "Modedefs.Bas"
Include "Irserout.Bas" ' Load in the New Subroutine
' ** Set Xtal Value in Mhz **
Define OSC 4 ' Set Xtal Frequency
' ** New Defines for IRSEROUT **
Define IRSEROUT_PORT PortB ' Set IRSEROUT Port
Define IRSEROUT_PIN 0 ' Set IRSEROUT Pin
Define IRSEROUT_BAUD 1200 ' Set IRSEROUT Baud Rate
' ** Declare Variables **
Counter Var Byte ' Count from 0 to 255
' ** Start of Program **
Start: Pause 400 ' Wait For the Pic to Initialize
Counter = 0 ' Clear Counter
Main: IR_Byteout = 254 ' Send the Control Code
Gosub IRSerout
IR_Byteout = 1 ' Send the Code for Clear LCD
Gosub IRSerout
Pause 30 ' Wait for Serial LCD to Recover
IR_Byteout = "R" ' Load the letter "R" into IR_ByteOut
Gosub IRSerout ' Send the Byte
IR_Byteout = "E" ' Load the letter "E" into IR_ByteOut
Gosub IRSerout ' Send the Byte
IR_Byteout = "C" ' Load the letter "C" into IR_ByteOut
Gosub IRSerout ' Send the Byte
IR_Byteout = "E" ' Load the letter "E" into IR_ByteOut
Gosub IRSerout ' Send the Byte
IR_Byteout = "I" ' Load the letter "I" into IR_ByteOut
Gosub IRSerout ' Send the Byte
IR_Byteout = "V" ' Load the letter "V" into IR_ByteOut
Gosub IRSerout ' Send the Byte
IR_Byteout = "E" ' Load the letter "E" into IR_ByteOut
Gosub IRSerout ' Send the Byte
IR_Byteout = "D" ' Load the letter "D" into IR_ByteOut
Gosub IRSerout ' Send the Byte
IR_Byteout = " " ' Load a Space into IR_ByteOut
Gosub IRSerout ' Send the Byte
' Send Out In 3 Digit Ascii, The Value Of Counter
IR_Byteout= Counter Dig 2
IR_Byteout=IR_Byteout+48
Gosub IRSerout ' Send the Byte
IR_Byteout= Counter Dig 1
IR_Byteout=IR_Byteout+48
Gosub IRSerout ' Send the Byte
IR_Byteout= Counter Dig 0
IR_Byteout=IR_Byteout+48
Gosub IRSerout ' Send the Byte
Pause 500 ' A Long Delay
Counter=Counter+1 ' Increment Counter
Goto Main ' Infinite Loop
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -