Posted by : Niam Tamami December 22, 2015

blognitbot.com



Wiring-x86 adalah modul python yang mengizinkan pengguna intel Galileo mengakses io nya seperti cara mengakses Arduino. Beberapa fitur yang telah ditawarkan oleh API (Aplication Programming Interface) dari intel Galileo mencangkup beberapa fitur di bawah ini.
Writing to a GPIO pin configured as output.
  • Reading from a GPIO pin configured as high impedance input.
  • Reading from a GPIO pin configured as pullup input.
  • Reading from a GPIO pin configured as pulldown input.
  • Reading from a GPIO pin configured as analog input (ADC).
  • Writing to a GPIO pin configured as analog output (PWM).


Berikut ini adalah cara menginstall library python Wiring-x86 pada intel Galileo.

Installing Wiring-x86

The first step is to install the Wiring-x86 module. There are several ways to do this.

Installing from a tarball

When using the original YOCTO Linux distribution provided with the board this is the easiest method to get the module installed. A tarball of the latest code can be downloaded from GitHub as follows:

$ curl -O -L http://github.com/emutex/wiring-x86/archive/master.tar.gz
 
Install it as follows:

$ tar zxvf master.tar.gz
$ cd wiring-x86-master/
$ sudo python setup.py install 
 
yang di warnai warna merah adalah bagian yang paling penting. Berikut ini adalah contoh dari penggunaan library Wiring-x86.

# Import the time module enable sleeps between turning the led on and off.
import time

# Import the GPIOGalileoGen2 class from the wiringx86 module.
from wiringx86 import GPIOGalileoGen2 as GPIO

# Create a new instance of the GPIOGalileoGen2 class.
# Setting debug=True gives information about the interaction with sysfs.
gpio = GPIO(debug=False)
pin = 13
state = gpio.HIGH

# Set pin 13 to be used as an output GPIO pin.
print 'Setting up pin %d' % pin
gpio.pinMode(pin, gpio.OUTPUT)


print 'Blinking pin %d now...' % pin
try:
    while(True):
        # Write a state to the pin. ON or OFF.
        gpio.digitalWrite(pin, state)

        # Toggle the state.
        state = gpio.LOW if state == gpio.HIGH else gpio.HIGH

        # Sleep for a while.
        time.sleep(0.5)

# When you get tired of seeing the led blinking kill the loop with Ctrl-C.
except KeyboardInterrupt:
    # Leave the led turned off.
    print '\nCleaning up...'
    gpio.digitalWrite(pin, gpio.LOW)

    # Do a general cleanup. Calling this function is not mandatory.
    gpio.cleanup()

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Entri Populer

tweet

- Copyright © 2013 blog.nitbot.com -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -