1

Im trying to read a GPIO Pin on my Raspberry Pi with python and dont know how to read more Values than just 0(LOW) or 1(HIGH) (GPIO.input) because i have this rotary Switch

GPIO.setup(15,GPIO.IN)
VALUE=GPIO.input(14)
knh190
  • 2,744
  • 1
  • 16
  • 30
  • What values are you imagining that a GPIO pin can have, other than 0 or 1? A rotary switch would presumably require multiple pins to interface - but you've given no details on which to base an answer. – jasonharper Apr 04 '19 at 19:27
  • Oh shoot, forgot the fact pins can only have 0 or 1....How would I have to set the switch up to be able to read more values ? – Hasenschnaps Apr 04 '19 at 19:29
  • Think in binary, if you had two pins you could have values 0, 1, 2, 3 (i.e. 00 01 10 11) – Martin Evans Apr 04 '19 at 19:33
  • So but there is no way to „digital read“ to read data out of sensors like you can on an arduino for example ? – Hasenschnaps Apr 04 '19 at 19:48

1 Answers1

0

I think this might help.
gpiozero:

import Button
from time import sleep

button = Button(2)

while True:
    if button.is_pressed:
        print("Pressed")
    else:
        print("Released")
    sleep(1)
SherylHohman
  • 16,580
  • 17
  • 88
  • 94
UNKNOWN
  • 105
  • 10