• Ehh say what you want but for me (that is a beginner with no understanding of Figure 16) this whole thing is getting hairy.

    After reading example codes I assumed that pin.write(!pin.read()) simply toggles given pin right? Well no, it turns out it's not that simple. It works like a toggle for an LED, but it doesn't work for a relay module.

    Yes you said charging capacitors and square waves, but I say toggling is more likely a beginner's thing.

  • After reading example codes I assumed that pin.write(!pin.read()) simply toggles given pin right? Well no, it turns out it's not that simple. It works like a toggle for an LED, but it doesn't work for a relay module.

    What?! pin.write(!pin.read()); should absolutely toggle the pin, unless you did pinMode(pin,'input') or something which would prevent it from writing the pin... That's wacky if it's not...

    The only way I can see that not working is if the relay draws so much current that even when the chip is trying to drive the pin high, the voltage isn't high enough to be a logical 1. Relays often draw more current that a microcontroller is designed to supply; if such a relay was connected directly, the 'high' output voltage (if it's active high) wouldn't be able to get up to 3.3v; the pico can only supply 20mA max, and I think at 20mA, it's significantly below Vcc - and if it was drooping low enough, it would be seen by pin.read() as a 0, not a 1.

    What's the voltage on the pin when you drive it high with the relay module connected?

About

Avatar for Rollo @Rollo started