Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
ip_selctor [2014/12/30 22:07]
admin
ip_selctor [2014/12/30 22:08]
admin
Line 39: Line 39:
   $ unzip master.zip   $ unzip master.zip
 Example:\\ Example:\\
-# Set IP Address with MCP23008 +  ​# Set IP Address with MCP23008 
- +  from Adafruit_MCP230xx import * 
-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) 
-# Use busnum = 0 for older Raspberry Pi's (256MB) +  mcp = Adafruit_MCP230XX(busnum = 1, address = 0x20, num_gpios = 8) 
-# Use busnum = 1 for new Raspberry Pi's (512MB with mounting holes) +  # Set pins to input with the pullup resistor enabled 
-mcp = Adafruit_MCP230XX(busnum = 1, address = 0x20, num_gpios = 8) +  for i in range(0,​8):​ 
-# Set pins to input with the pullup resistor enabled +    mcp.pullup(i,​ 1) 
-for i in range(0,​8):​ +  # Read pins and display the results 
-  mcp.pullup(i,​ 1) +  #bitshift output, third bit is the output 
-# Read pins and display the results +  meineIP=0 
-#bitshift output, third bit is the output +  for i in range(0,​8):​ 
-meineIP=0 +    print "%d: %x" % (i, mcp.input(i) >> i) 
-for i in range(0,​8):​ +    meineIP = meineIP +  mcp.input(i) 
-  print "%d: %x" % (i, mcp.input(i) >> i) +  print meineIP
-  meineIP = meineIP +  mcp.input(i) +
-print meineIP+