On 31/08/2023 22:15, Chris Green via Python-list wrote: > class Gpiopin: > > def __init__(self, pin): > # > # > # scan through the GPIO chips to find the line/pin we want > # > for c in ['gpiochip0', 'gpiochip1', 'gpiochip2', 'gpiochip3']: > > chip = gpiod.Chip(c) > for l in range(32): > line = chip.get_line(l) > if pin in line.name(): > print("Found: ", line.name()) > return > else: > raise ValueError("Can't find pin '" + pin + "'")
You don't store the line anywhere. You need to use self.line self.line = chip.get_line(l) if pin... > def print_name(self): > print (self.line.name()) > > def set(self): > self.line.set_value(1) > > def clear(self): > self.line.set_value(0) As you do here. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list