The next part is assembling all the components together. The Raspberry Pi 2 (in this case) contains a single 40-pin ex-pansion header labeled as ‘J8’ providing access to 26 GPIO pins[1] which is illustrated in Fig. 4.
Fig. 4.Raspberry Pi J8 Header
Since Pi4J will be used as an external library which enables us to control the GPIO pins using Java Fig.5 illustrates the GPIO pinout using the Pi4J [18] numbering scheme. Fig. 5. GPIO Pinout of Raspberry Pi using Pi4J
After completely understanding the pinout of Raspberry Pi the (Fig. 6) will help us understand how the components are to be connected with the pi and it will also help us understand the flow of data in the Brain-Bot. Fig. 6. Flow of Data
In the above chart …show more content…
Here, Raspberry Pi will act as a server which will open a socket on a specified port which will wait for the incoming connection from the client machine once the connection is established it will send and receive messages and the connection will termi-nate only when the client side application exits. As mentioned earlier it is similar to a simple chat server where the client ma-chine will send some instructions as messages and the Pi will send acknowledgment or error message as message only. One thing that should be kept in mind here is that in the case of an error the server side code should not terminate. Now from here code can be further divided into five parts i.e.:
4.1 Sever Side Code
Server side code will include the portion of opening a socket on a specific port as discussed earlier and in addition to it there will be some if-else construct or a switch case implementation that will interpret the incoming instructions from the client ma-chine and will call the related method associated with the in-struction