homieiot / homie-esp8266

💡 ESP8266 framework for Homie, a lightweight MQTT convention for the IoT
http://homieiot.github.io/homie-esp8266
MIT License
1.36k stars 308 forks source link

Fix for LightOnOff example #200

Closed AlexValois closed 7 years ago

AlexValois commented 7 years ago

Hi,

I think there is a little error in the LightOnOff sketch example. digitalWrite(PIN_RELAY, on ? HIGH : LOW); should be digitalWrite(PIN_RELAY, on ? LOW : HIGH); Thanks again for the great job on Homie-esp8266 !

Alex

Update : after new compilation, the behavior is correct...don't really understand why. Please ignore this issue.

euphi commented 7 years ago

Mmhm? If it is needed to switch the output to HIGH or LOW to switch the light/LED on, depends on how you wire the output.

It is more usual* to connect collector or cathode (e.g. of ULN2003) to the output, so in this case it is necessary to switch to LOW for on.

If you connect a single LED with its anode or an n-type FET you would need to send HIGH for on.


*) As most microcontrollers, the ESP8266 can sink more current than it can source.