Getting signals from the outside world

You know how to send signals to the outside world. You might also want to receive input signals from the outside world. These signals can be divided into two types: digital signals and analog signals.

Interfacing digital input signals with Galileo

There are pins on the GPIO connectors of the Galileo than can be used to sense digital input; that is, an input that will be interpreted as either a 0 or 1 by a program. These are labelled on the Galileo. An example of how to use these is a simple button press circuit. To create this circuit, you'll need one of the 220-ohm resistors you used in the LED circuit. You'll also need a simple, single-pole, single-throw switch; you can get these at most electronics stores. You'll also need some jumper wires to connect the Galileo to your circuit. Here is the circuit diagram:

Interfacing digital input signals with Galileo

Now you'll need some code. You can use one of the example programs included with the IDE. Select the Examples | 02.Digital | Button code, like this:

Interfacing digital input signals with Galileo

When you upload this example, you will find that pressing the button lights the LED on the Galileo board. When you release the button, the LED will not be lit. You can now get digital input into your project.

Interfacing analog input signals with Galileo

There are some signals that aren't either on, or off. You will actually want to measure the level of the signal. These are analog signals, and the Galileo can handle them as well. You'll need to use one of the analog inputs, however. These are also labelled on the board. As an example, you can build a simple electronic circuit using a potentiometer to illustrate this capability. A potentiometer is a variable resistor; you can change the resistance between two points by adjusting the potentiometer, normally by turning an adjustment either with your fingers, or a screwdriver. To create this circuit, you'll need a potentiometer, available at almost all electronics stores. Here is the circuit to build:

Interfacing analog input signals with Galileo

You have to connect the 5-volt connection to one side of the potentiometer, and the GND connection to the other side of the connector. The middle terminal of the potentiometer will change voltage value as you adjust the potentiometer. To measure this voltage, you'll use another example program that comes with the IDE. Select the Examples | 03.Analog | AnalogInput, code like this:

Interfacing analog input signals with Galileo

Adjusting the potentiometer will cause the LED on the Galileo to flash faster or blink more slowly. The Galileo is reading the voltage value and using that value to determine how long the LED should be on and off. You can now get analog input into your Galileo.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.11.226