Quickly testing a GPIO pin
To set pin GPIO_PH1 as an output:
sudo su (Enter your user password. Defaults to "ubuntu") # See which pins are currently configured as GPIO, and what their state is. cat /sys/kernel/debug/gpio # Validate that the entry for the Tegra GPIO controller has a base value of 0. If not, add on whatever the base value is to the “57” in the commands below.
echo 57 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio57/direction echo 1 > /sys/class/gpio/gpio57/value
Put a voltmeter on pin 50 (gpio57) of the 2-row header (J3A1) & pin 2 (GND) also of the 2-row header, as shown in the following photo:
You should now see that it is at +1.8V. This pin is LCD_BL_PWM (GPIO_PH1). Setting it to 0:
echo 0 > /sys/class/gpio/gpio57/value
You should now see that it is at 0.0V (roughly).
Once you’re done:
echo 57 > /sys/class/gpio/unexport exit
Turning an LED on/off or sending a signal to an Arduino microcontroller from Jetson TK1
You can now set a 1.8V voltage on a GPIO pin, but the GPIO pins on Jetson TK1 don't have enough electrical current or power to connect directly to an LED and also, 1.8V is a lower voltage than you normally want. So the easiest way to control a single LED from Jetson TK1 is to build a transistor switch circuit, as shown in the circuit diagram:
The following photo shows this circuit when built on veroboard. (Copper tracks under the board are highlighted in yellow). It includes a white wire that can optionally be attached to an Arduino or other microcontroller that takes a 5V input signal:
Connect the red wire (+5V) to pin 1 on J3A1 (bottom-right pin of the dual-row header, next to the text saying "DISPLAY TOUCH") to power the LED from Jetson TK1.
Now if you use the commands above (with root permissions) to turn the GPIO pin high/low, you should see the LED turn on/off and the optional wire should switch between roughly +5V and 0V. Note that this wire is using inverted logic, so it will be at around +5V when the GPIO pin is set to low (0) and around 0V when the GPIO pin is set to high (1), since the transistor acts as an inverting switch.
- how this transistor switching circuit works,
- using other pins or other voltages,
- bidirectional level-shifters that allow you to read & write multiple 5V signals,
- other communication protocols besides simple GPIO such as I2C.