using GPIO Reading from 4 inputs give me non accurate output - Raspberry Pi Forums
i trying read 4 inputs integer value when test code actual values not match expected
my code: so, want know problem in code?
my code:
code: select all
import rpi.gpio gpio import os, time i=0 gpio.setmode(gpio.bcm) gpio.setwarnings(false) gpio.setup(22,gpio.in) gpio.setup(23,gpio.in) gpio.setup(4,gpio.in) gpio.setup(17,gpio.in) gpio.setup(27,gpio.out) = [0,0,0,0,0] while true: n1=gpio.input(22) n2=gpio.input(23) n3=gpio.input(4) n4=gpio.input(17) if(n1==0): if(n2==0): if(n3==0): if(n4==0):#0000 a[i]=0 if(n1==0): if(n2==0): if(n3==0): if(n4==1):#0001 a[i]=1 if(n1==0): if(n2==0): if(n3==1): if(n4==0):#0010 a[i]=2 if(n1==0): if(n2==0): if(n3==1): if(n4==1):#0011 a[i]=3 if(n1==0): if(n2==1): if(n3==0): if(n4==0):#0100 a[i]=4 if(n1==0): if(n2==1): if(n3==0): if(n4==0):#0101 a[i]=5 if(n1==0): if(n2==1): if(n3==1): if(n4==0):#0110 a[i]=6 if(n1==0): if(n2==1): if(n3==1): if(n4==1):#0111 a[i]=7 i=i+1 print if(i==5): break
hi,
code output?
connected input pins?
texy
code output?
connected input pins?
texy
raspberrypi
Comments
Post a Comment