Jump to content

OrangePi Zero - GPIO question


MichalBor

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines