5

Can you give me an idea on how to check the statuses of specific GPIO pins if it is HIGH or LOW? My project is all about checking the statuses of GPIO pins (6 GPIO pins). I want to check all of the pins at once and if all pins are high the want to capture a photo and upload on website. I use scripting in my coding.

1
  • If I understand you correctly, you could use python and check if GPIO 1 is HIGH ---> if so under that if create another if that checks if GPIO 2 is HIGH. Do that for each if, nesting it under the last if and in the last one: if GPIO 6 == high --> takePhoto() and upload() where takePhoto() and upload() are functions to take the photo and upload it.
    – NULL
    Apr 8, 2016 at 16:39

1 Answer 1

4

Using the pigpio lib you can read full 32 bit wide banks of GPIO pins at once. It also provides a pythonized interface, see here:

read_bank_1()

Returns the levels of the bank 1 GPIO (GPIO 0-31).

The returned 32 bit integer has a bit set if the corresponding GPIO is high. GPIO n has bit value (1 << n).

Example

print(bin(pi.read_bank_1()))

0b10010100000011100100001001111

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.