blinkOnPin0.ino 655 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. Blink led on PIN0
  3. by Mischianti Renzo <http://www.mischianti.org>
  4. https://www.mischianti.org/2019/01/02/pcf8574-i2c-digital-i-o-expander-fast-easy-usage/
  5. */
  6. #include "Arduino.h"
  7. #include "PCF8574.h"
  8. // Set i2c address
  9. PCF8574 pcf8574(0x39);
  10. void setup()
  11. {
  12. Serial.begin(115200);
  13. delay(1000);
  14. // Set pinMode to OUTPUT
  15. pcf8574.pinMode(P0, OUTPUT);
  16. pcf8574.pinMode(P1, INPUT);
  17. Serial.print("Init pcf8574...");
  18. if (pcf8574.begin()){
  19. Serial.println("OK");
  20. }else{
  21. Serial.println("KO");
  22. }
  23. }
  24. void loop()
  25. {
  26. pcf8574.digitalWrite(P0, HIGH);
  27. delay(1000);
  28. pcf8574.digitalWrite(P0, LOW);
  29. delay(1000);
  30. }