We're no longer updating This wiki!!

Use to U3 Shield Tinkering Kit

This page introduces how you can use a Tinkering Kit compatible U3 IO Shield.

Using a dual color LED and push button switch.

1. Hardware settings.

2. ODROID-U3 settings.
You will use GPIO-I2C to comunication with U3 IO Shield.

sudo modprobe i2c_dev
sudo modprobe i2c-gpio-custom bus0=4,200,199

To use externel IO port of U3 IO Shield you will attach tca6416 gpio driver to i2c-gpio.4 bus.

echo tca6416 0x20 > /sys/devices/platform/i2c-gpio.4/i2c-4/new_device

Now, you can use GPIO #301 ~ #304 in the Tinkering Kit.

echo 302 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio302/direction
echo 1 > /sys/class/gpio/gpio302/value

3. Bash shell script example

#!/bin/bash                                                                     
 
GPIOPATH="/sys/class/gpio"                                                      
 
echo 301 > $GPIOPATH/unexport                                                   
echo 302 > $GPIOPATH/unexport                                                   
echo 303 > $GPIOPATH/unexport                                                   
 
echo 301 > $GPIOPATH/export                                                     
echo 302 > $GPIOPATH/export                                                     
echo 303 > $GPIOPATH/export                                                     
 
echo in > $GPIOPATH/gpio302/direction                                           
echo out > $GPIOPATH/gpio302/direction                                          
echo out > $GPIOPATH/gpio303/direction                                          
 
while true :                                                                    
do                                                                              
        cat=($(cat $GPIOPATH/gpio301/value))                                    
        if [ $cat -eq 0 ]; then                                                 
                pushed=1                                                        
        fi                                                                      
        if [[ ($cat -eq 1) && ($pushed -eq 1) ]]; then                          
                pushed=0                                                        
                cnt=$((($cnt + 1)%4))                                           
        fi                                                                      
 
        case $cnt in                                                            
                0) echo 0 > $GPIOPATH/gpio302/value                             
                   echo 0 > $GPIOPATH/gpio303/value ;;                          
                1) echo 1 > $GPIOPATH/gpio302/value                             
                   echo 0 > $GPIOPATH/gpio303/value ;;                          
                2) echo 0 > $GPIOPATH/gpio302/value                             
                   echo 1 > $GPIOPATH/gpio303/value ;;                          
                3) echo 1 > $GPIOPATH/gpio302/value                             
                   echo 1 > $GPIOPATH/gpio303/value ;;                          
        esac                                                                    
 
        sleep 0.1                                                               
done
en/u3_shield_tinkering.txt · Last modified: 2015/02/02 12:09 by john1117
CC Attribution-Share Alike 3.0 Unported
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0