Robs Homepage ... motivated by exploring software solutions

Experiment [IN PROGRESS]


A blinking LED, connected to the Raspberry Pi GPIO (General Purpose Input/Output Pins) controlled via Browser.
Functions: Start / Stop Blinking (Button), specify the blinking interval in ms (Input Field) and display LED status with blinking counter (Label).

Ready to develop?

Before starting, ensure to read Get Ready first.


Raspberry Pi, GPIO Extension Board, GPIO cable, Breadboard, 1 Resistor 330 ohm, 1 LED 3.3 V, several jumper wires.
Build the circuit (see also picture at the right)
The Pi GPIO is connected va a GPIO Extension Board (T-Cobbler) and GPIO cable to a Breadboard.
On the Breadboard, place the LED with a 330 ohm resistor in series with the GND (Physical Pin 6) and the GPIO18 Pin (Physical Pin 12, Pi4J GPIO1).
Create the Software
A B4J server application using the jPi4J Libary (Raspberry Pi GPIO controller).
For detailed information about the project see Description below or look up in project source.
Run the Experiment
On the Pi start the B4J-Bridge by login on as user Pi, open a terminal, go to folder /home/pi/b4j and run $sud0 java -jar b4-bridge.jar, note the MyIp address.
Open the B4J IDE and load bloinkingled.b4j, connect to the B4J-Bridge (Menu Tools > B4J Bridge > Connect > Enter IP address.
Run the application from the B4J IDE by pressing F5.
Open a Browser and enter as URL the Pi IP Address:port, like
Click the Switch Timer button and if all is well, the LED will start to blink.


file_download the project source.



The Concept


Projectfile blinkingled.b4j
The project file blinkingled.b4j defines and starts the server. The server requires the library jServer.
'Make the server public as accessed from other modules
Public srvr As Server
srvr.Port = 51042
'Add the websocket. Note that in index.html the connection to main is defined as script: b4j_connect("/main");
srvr.AddWebSocket("/main", "Experiment")
'Init the GPIO Controller
'Start the server and get going

Websocket Class Experiment.bas
Code Module Controller.bas