Reputation: 11
hello i made this code but its not working well can you please help me
i need to read all the exit and execute an action but when the code read the pin 65 for example he dont read the pin 82 and that not what i want
i got 2 mcp23017 connected to the raspberrypi and need to read 32 exit
from cmath import pi
from turtle import delay
import wiringpi
from time import sleep
pin_base = 65 # lowest available starting number is 65
i2c_addr = 0x21 # A0, A1, A2 pins all wired to GND
i2c_addr_2 = 0x23
#pins = [65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80]
#pins = [73,74,75,76,77,78,79,65,66,67,68,69,70,71,72,73]
# [____________________]
# !
# MCP1 ENTREE
wiringpi.wiringPiSetup() # initialise wiringpi
wiringpi.mcp23017Setup(pin_base,i2c_addr) # set up the pins and i2c address
wiringpi.mcp23017Setup(pin_base+16,i2c_addr_2)
# Note: MCP23017 has no internal pull-down, so I used pull-up and inverted
# the button reading logic with a "not"
while True:
for pin in range(65,72):
wiringpi.delay(80)
print(pin)
wiringpi.pinMode(pin,1)
pins=wiringpi.digitalRead(pin)
if (pins==0):
pin = pin + 8
wiringpi.digitalWrite(pin,0)
print('//1//')
print(pin)
pin = pin - 8
wiringpi.delay(80)
if (pins==1):
pin = pin + 8
wiringpi.digitalWrite(pin,1)
print('//2//')
print(pin)
pin = pin - 8
wiringpi.delay(80)
for pin in range(81,88):
wiringpi.delay(80)
print(pin)
wiringpi.pinMode(pin,1)
pins=wiringpi.digitalRead(pin)
if (pins==0):
pin = pin + 8
wiringpi.digitalWrite(pin,0)
print('//1//')
print(pin)
pin = pin - 8
wiringpi.delay(80)
if (pins==1):
pin = pin + 8
wiringpi.digitalWrite(pin,1)
print('//2//')
print(pin)
pin = pin - 8
wiringpi.delay(80)
print(pin)
wiringpi.delay(80)
Upvotes: 1
Views: 70