'=================================================================== ' Demonstration program for RF24G as a transmitter '=================================================================== Peripheral myT As RF24G @ 0 ' Set the module ID as 0 Dim g_bTxReady As Byte ' Declare the variable for the transmission status Sub Main() ' Main program starts here Dim bTx As Byte ' Declare the variable for the data to be transmitted Debug CLS ' Clear the terminal display myT.SetMode(0) ' Set the mode as transmission mode myT.SetCh(0) ' Set the transmission channel as 0 myT.SetRFID(0) ' Set the ID code as 0 myT.SetRegCode(0) ' Set the Reg code as 0 myT.EnTxReadyEvent() ' Enable the transmission complete notification Event myT.Config() ' Update the setting values '------------------------------------------------------------------- ' Use the FOR loop to repeat the transmission operation a hundred times '------------------------------------------------------------------- For bTx=1 To 100 ' Perform the FOR loop a hundred times g_bTxReady = 0 ' Clear the transmission status myT.SendVar(bTx) ' Transmit the content of bTx '------------------------------------------------------------------- ' Use the DO loop to wait for the completion of the transmission operation '------------------------------------------------------------------- Do Loop Until g_bTxReady=1 Debug CSRXY(1, 1), %DEC3R bTx ' Display the transmitted values on the terminal display Pause 1000 ' Wait for a period of time before the receiver starts receiving Next Debug CSRXY(1, 2), "Transmission complete" ' Display that the transmission is complete End Sub Event myT.TxReadyEvent() ' Notification event for transmission complete g_bTxReady = 1 ' Set the transmission status as 1 End Event