[Swlug] Other peoples code!
Rhys Sage
rhys_sage at yahoo.com
Sun Nov 13 01:43:27 UTC 2022
It's one of my biggest frustrations. People have code online that they claim works then when I download it and run it, it does not. Then I have to fault find. Scratching my head a bit on this one because I'm a bit out of my depth.
The main program has the following call..
import pcf8574
from machine import I2C, Pin
import time
i2c = I2C(0)
pcf = pcf8574.PCF8574(i2c, 0x20) <---- this causes an error about a missing attribute PCF8574
while True:
pcf.port = 0xff
time.sleep(0.5)
The library starts off...
class PCF8574:
def __init__(self, i2c, address=0x20):
self._i2c = i2c
self._address = address
self._port = bytearray(1)
if i2c.scan().count(address) == 0:
raise OSError('PCF8574 not found at I2C address {:#x}'.format(address))
I know the error is probably bloody simple. I do know that my PCF8574 is indeed at 0x20 because I ran a scan. The problem is my lack of knowledge of python and hence my ability to fix whatever was not right in the files I copied and pasted.
Anybody got any suggestions?
The next online meeting I should be able to catch maybe the last few minutes again. Wednesday is the day I do the driving - unless they throw me on another bus on an unknown route with just a route description on paper again. They did that to me last week.
Oh and I didn't win the election. They elected two people well known for their corruption which was frustrating.
Rhys Sage
More information about the Swlug
mailing list