BLUETOOTH-LINK

藍牙模組

Bluetooth 2.0
D-16  
C-16
Slot
0 1 2 3
4 5 6 7
當按下按鈕時(OFF->ON),會發出一字串"PUSH 123",經BLUETOOTH-LINK給在電腦端的Putty
 

B4R = Basic4Arduino

rCore rSoftwareSerial
Sub Process_Globals
	'These global variables will be declared once when the application starts.
	'Public variables can be accessed from all modules.
	Public serial1 As Serial
	
	Public blue As SoftwareSerial
	Public astream As AsyncStreams	
	Public n1 As Int=0	
	Private btnA0 As Pin	
End Sub

Private Sub AppStart
	serial1.Initialize(115200)
	Log("AppStart")
	' 
	btnA0.Initialize(btnA0.A0,btnA0.MODE_INPUT) '+5
	btnA0.AddListener("BtnA0_StateChanged")	
	'
	blue.Initialize(9600, 15, 14)
	astream.Initialize(blue.Stream, "astream_NewData", Null)
End Sub
'
Sub astream_NewData (Buffer() As Byte)
	
End Sub
'
Sub BtnA0_StateChanged(State As Boolean)
	If State Then		
		n1=n1+10
		Dim ss As String=JoinStrings(Array As String("PUSH ",NumberFormat(n1,3,0)))
		astream.Write(ss.GetBytes)
		astream.Write(Array As Byte(10,13))
		Log("ss = ",ss)
	End If	
End Sub