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.
-
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.– NULLApr 8, 2016 at 16:39
1 Answer
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