Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[arduino code examples for A6v3]-01 Turn ON/OFF OUTPUT
#1
Code:
/*
Blink led on PIN0
by Mischianti Renzo <http://www.mischianti.org>

https://www.mischianti.org/2019/01/02/pcf8574-i2c-digital-i-o-expander-fast-easy-usage/
*/

#include "Arduino.h"
#include "PCF8574.h"

// Set i2c address
PCF8574 pcf8574(0x24);

void setup()
{
  Wire.begin(12, 11); // SDA: GPIO12, SCL: GPIO11
    Serial.begin(115200);
//    delay(1000);

    // Set pinMode to OUTPUT
    pcf8574.pinMode(P0, OUTPUT);
  pcf8574.pinMode(P1, OUTPUT);
  pcf8574.pinMode(P2, OUTPUT);
  pcf8574.pinMode(P3, OUTPUT);
  pcf8574.pinMode(P4, OUTPUT);
  pcf8574.pinMode(P5, OUTPUT);


  pcf8574.digitalWrite(P0, HIGH);
  pcf8574.digitalWrite(P1, HIGH);
  pcf8574.digitalWrite(P2, HIGH);
  pcf8574.digitalWrite(P3, HIGH);
  pcf8574.digitalWrite(P4, HIGH);
  pcf8574.digitalWrite(P5, HIGH);

    Serial.print("Init pcf8574...");
    if (pcf8574.begin()){
        Serial.println("OK");
    }else{
        Serial.println("KO");
    }
}

void loop()
{
    delay(300);
    pcf8574.digitalWrite(P0, LOW);
  delay(300);
  pcf8574.digitalWrite(P1, LOW);
  delay(300);
  pcf8574.digitalWrite(P2, LOW);
  delay(300);
  pcf8574.digitalWrite(P3, LOW);
  delay(300);
  pcf8574.digitalWrite(P4, LOW);
  delay(300);
  pcf8574.digitalWrite(P5, LOW);
  delay(300);
}
arduino ino file download:
.zip   8574-DO.zip (Size: 594 bytes / Downloads: 10)
BIN file (you can use esp32 download tool download to ESP32-S3 with address 0x0 then directly to use) download:
.zip   8574-DO.ino.merged.zip (Size: 191.2 KB / Downloads: 16)
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)