 
	This example demonstrates how a Raspberry Pi board can be controlled from the browser.
It tracks the switches state and allows the user to turn on and off the 8 leds.
The toggle buttons are based on this jQuery plugin: http://simontabor.com/labs/toggles/
The server code is quite simple. All the active connections are stored in a Map. This map is used to notify all connections about the switches events:
			
				B4X:
			
		
		
		Sub HandleSwitch(index As Int, State As Boolean)
   'notify all active connections about the switch state change.
   For Each wsm As WebSocketModule In connections.Keys
     CallSubDelayed3(wsm, "SwitchStateChanged", index, State)
   Next
End SubThe leds are toggled with this code:
			
				B4X:
			
		
		
		Public Sub Led_Toggle(Params As Map)
   Dim id As String = Params.Get("id") 'id will be ledx
   Dim active As Boolean = Params.Get("active")
   Main.pface.GetLED(id.SubString(3)).State = active
End SubYou should use B4J-Bridge to connect to the Raspberry Pi during development. Note that the www folder is not copied automatically during deployments. You need to copy the files whenever a static file is changed.
 
	See this link for more information about jPi4J library: http://www.b4x.com/android/forum/threads/jpi4j-raspberry-pi-gpio-controller.37493/#content
 
				 
 
		 
 
		
 
	 
 
		 
 
		 
 
		 
 
		