It was working perfectly up until this evening. I have reinstalled all the software and I have also tried powering down the RPi and removing the hat and then trying to run the same code again and I get the same message. It’s like it can’t detect the hat any more. Any suggestions? I’m using a Pi 2 with the newest version of Raspian and everything seems up to date. Thanks in advance.

I’d guess it’s a software problem, rather than a hardware one, since the software just blindly throws data out of a pin and doesn’t care if you’ve got a HAT connected or not.

I’ll have to investigate and see if I can recreate it. In the meantime, I’m pretty sure a new Raspbian image will get it up and running if you’ve got a spare SD card. A little drastic, but re-imaging generally fixes all woes of this nature.