MichalBor Posted February 18, 2017 Posted February 18, 2017 Hi, I have probably trivial question related to GPIO on Orange Pi Zero. So - I have a switch there connected ot 3.3V and then to GPIO (pin 12 on Zero). What I want to do is just to read GPIO state. When button pressed it goes to high state - normally. On RaspberryPi and Odroid C1 that works fine just using basic code with wiringpi2 or eventually wiringpi. So I tried the same on Zero compiling wiring for H3/H2. My code is basic in Python: import time import wiringpi import pyA20 as GPIO cykl = 1 wiringpi.wiringPiSetupGpio #or wiringPiSetup() wiringpi.pinMode(1,0) while cykl == 1 : do_call = wiringpi.digitalRead(1) if do_call: print 'pressed' time.sleep(0.05) On other arm machines it works. Did I missed something with ZERO? I do not have any error - but so far I never got change of the state to 1. I assume in mapping PIN 12 is GPIO1 or eventually GPIO7. Is this correct? I think I have missed something there - probably very basic..... Thanks in advance for help.... Michal
martinayotte Posted February 19, 2017 Posted February 19, 2017 Why are you using the wiringpi ? I'm using the https://github.com/duxingkei33/orangepi_PC_gpio_pyH3 instead, and simple code like : from pyA20.gpio import gpio from pyA20.gpio import port gpio.init() gpio.setcfg(port.PA7, gpio.INPUT) print gpio.input(port.PA7) 1
MichalBor Posted February 19, 2017 Author Posted February 19, 2017 Thanks Martin, That is true... I should go with easy way. I think I was just too much focus and used to Wiringpi.... Actually I even compiled that library before... but never used. Looks like this works... There is only one small issue which I see I have with that button. My button is piezoelectric - unfortunately on this type you have small leakage of voltage (very low) from time to time. And unfortunately it is read as signal. Maybe somebody has idea if in digital mode I can set up at which level it should react? Or do I have to set up physical electronic filter before sending this to GPIO input? For now I have like 90% state 0 but 10% randomly jumps to 1. If there is no good way then I would need to jump to physical button and give up with piezoelectric one. I know it is more electronic question... but if somebody is using GPIO - then there is electronic behind.... pyA20 solution works perfectly fine.... but my button not... Thanks again for assistance Michal
jkajolin Posted February 19, 2017 Posted February 19, 2017 You can not do anything for the digital pin rules, the difference between low and high is hardcoded. From what I understand there is no single value for the threshold but it works on higher than some targed value...Some logic coverter might work but I think you need analog device which basic socs do not support Maybe somebody has idea if in digital mode I can set up at which level it should react? Or do I have to set up physical electronic filter before sending this to GPIO input?
MichalBor Posted February 19, 2017 Author Posted February 19, 2017 Yeap... values float a little. I was just thinking if method like pullup or puldown would not help.... But to be honest I'm not sure if I can use that and how in easy way. For now it looks like I have to revert to analogue push button Mike
Recommended Posts