Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
ip_selctor [2014/12/30 18:25]
admin
ip_selctor [2014/12/30 22:08]
admin
Line 20: Line 20:
 Check the i2c modules:\\ Check the i2c modules:\\
   $ lsmod   $ lsmod
 +  
 +  Module                  Size  Used by
 +  i2c_dev                 3792 
 +  i2c_bcm2708             3408 
 +Install some programs:\\
 +  $ sudo apt-get update
 +  $ sudo apt-get install i2c-tools
 +  $ sudo apt-get install python-smbus
 +Check the address:\\
 +  $ sudo i2cdetect -y 1
 +  $ sudo i2cdump -y 1 0x20
  
-Library:\\+**Library:**\\
 [[https://learn.adafruit.com/mcp230xx-gpio-expander-on-the-raspberry-pi/overview]]\\ [[https://learn.adafruit.com/mcp230xx-gpio-expander-on-the-raspberry-pi/overview]]\\
 +Download Adafruit libraries:\\
 +  $ wget https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/archive/master.zip
 +unpack:\\
 +  $ unzip master.zip
 +Example:\\
 +  # Set IP Address with MCP23008
 +  from Adafruit_MCP230xx import *
 +  # Use busnum = 0 for older Raspberry Pi's (256MB)
 +  # Use busnum = 1 for new Raspberry Pi's (512MB with mounting holes)
 +  mcp = Adafruit_MCP230XX(busnum = 1, address = 0x20, num_gpios = 8)
 +  # Set pins to input with the pullup resistor enabled
 +  for i in range(0,8):
 +    mcp.pullup(i, 1)
 +  # Read pins and display the results
 +  #bitshift output, third bit is the output
 +  meineIP=0
 +  for i in range(0,8):
 +    print "%d: %x" % (i, mcp.input(i) >> i)
 +    meineIP = meineIP +  mcp.input(i)
 +  print meineIP
 +
 +