25.2.2 GPIO Port Details
25.2.2.1 GPIO Basics
There are various kinds of GPIO interface pins in Raspberry Pi. Each pin has its own purpose, and several pins are used together to make a specific circuit.
● DNC (Do Not Connect )
25.2.2 GPIO Port Details
25.2.2.1 GPIO Basics
There are various kinds of GPIO interface pins in Raspberry Pi. Each pin has its own purpose, and several pins are used together to make a specific circuit.
● DNC (Do Not Connect )
25.2 GPIO Details
25.2.1 GPIO Device
25.2.1.1 GPIO Pin Layout
Since Raspberry Pi B+ model, Raspberry Pi board has a 40-pin GPIO connector with 2 male headers arranged on the left side of SD card slot. The spacing between each header is 2.54 mm (0.1 inches), which is one of the standard spacings used in electronics and is the standard spacing for prototyping platforms including stripeboard and breadboard.
25.1 Raspberry Pi and External Interface
25.1.1 Meaning of External Interface
Standard PCs like regular desktops can run the same program much faster than Raspberry Pi. However, Raspberry Pi has a capability that these standard PCs can not provide, which is a bidirectional interface with external devices. Raspberry Pi can communicate with and control devices outside the system through an interface with external devices. It can receive input or output through an external device, or control the external device. It is possible to receive a various measuring values from an external sensor, to determine the situation, and to perform appropriate processing accordingly, or to build a system for directly controlling an external system by creating an embedded program.
Chapter 25 External Interface
Chapter’s Main Topics
Raspberry Pi can communicate with and control devices outside the system through an interface with external devices. The core device of the Raspberry Pi used here is GPIO (General Purpose Input Output) port. Here, we discuss how to interface with external devices using GPIO.
It includes descriptions on the following topics:
■ GPIO Details
■ Fundamentals of electricity/electronics
■ Fundamentals of Electronic circuit
■ Preparing interface
■ GPIO Library
■ Digital Input/Output interface
■ Interface using sensor
24.4.9 Including PHP Script File
PHP provides a way to insert ans use the text/code/markup in a specific file into the current working document. This function is very useful when you need to repeatedly use the same PHP, HTML, or text on multiple pages in PHP.
In PHP, “include” or “require” statement allows a web server to insert the contents of a particular PHP file into the PHP file of current document before executing a particular document.
24.4.8 Function
24.4.8.1 Definition of Function
Function is a unit of statements that can be executed repeatedly within a program. Users can freely define and use a function with arbitrary contents under certain constraints. It is defined in the following format.
function functionName( argument1, argument2, argument3…) {
code to be executed;
[ return; ]
code to be executed;
}
24.4.7 Stop and Return of Processing
24.4.7.1 “exit” Statement and “die” Statement
“exit” statement is a command that prints the specified message and terminates the execution of the PHP script. “die” statement is the same command as “exit” statement.
exit ( [ status-message ] )
exit ( [ status-number ] )
24.4.6 Execution Control
24.4.6.1 Conditional Control
The base value for determining “True” or “False” in the conditional expression is as follows.
■ False — zero
■ True — 1 or non zero
24.4.5 Output
You can use “echo” and “print” commands to print processing results in PHP. Both perform almost the same function. The text to be processed may include an HTML tag.
24.4.5.1 “echo” Command
“echo” command has no return value and can process several parameters simultaneously.
24.4.4 Operation
There are a number of operations supported by PHP as follows:
■ Arithmetic operation
■ Assignment operation
■ Comparison operation
■ Incremental/ Decremental operation
■ Logical operation
■ String operation
■ Array operation