Initial commit

This commit is contained in:
2026-03-31 13:17:21 +02:00
commit 7eeecff042
6821 changed files with 3514215 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
/*
Blink led on PIN0
by Mischianti Renzo <http://www.mischianti.org>
https://www.mischianti.org/2019/01/02/pcf8575-i2c-digital-i-o-expander-fast-easy-usage/
*/
#include "Arduino.h"
#include "PCF8575.h"
// Set i2c address
PCF8575 pcf8575(0x20);
void setup()
{
Serial.begin(115200);
// Set pinMode to OUTPUT
pcf8575.pinMode(P0, OUTPUT);
pcf8575.begin();
}
void loop()
{
pcf8575.digitalWrite(P0, HIGH);
delay(1000);
pcf8575.digitalWrite(P0, LOW);
delay(1000);
}

View File

@@ -0,0 +1,76 @@
/*
* PCF8575 GPIO Port Expand
* http://nopnop2002.webcrow.jp/WeMos/WeMos-25.html
*
* PCF8575 ----- WeMos
* A0 ----- GRD
* A1 ----- GRD
* A2 ----- GRD
* VSS ----- GRD
* VDD ----- 5V/3.3V
* SDA ----- GPIO_4
* SCL ----- GPIO_5
* INT ----- GPIO_13
*
* P0 ----------------- BUTTON0
* P1 ----------------- BUTTON1
* P2 ----------------- BUTTON2
* P3 ----------------- BUTTON3
* P4 ----------------- BUTTON4
* P5 ----------------- BUTTON5
* P6 ----------------- BUTTON6
* P7 ----------------- BUTTON7
*
*/
#include "Arduino.h"
#include "PCF8575.h" // https://github.com/xreef/PCF8575_library
#define ESP8266_INTERRUPTED_PIN 13
// Set i2c address
PCF8575 pcf8575(0x20);
// Function interrupt
bool keyPressed = false;
void keyPressedOnPCF8575(){
// Serial.println("keyPressedOnPCF8575");
keyPressed = true;
}
void setup()
{
Serial.begin(9600);
pinMode(ESP8266_INTERRUPTED_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(ESP8266_INTERRUPTED_PIN), keyPressedOnPCF8575, FALLING);
for(int i=0;i<8;i++) {
pcf8575.pinMode(i, INPUT);
}
pcf8575.begin();
}
void loop()
{
if (keyPressed){
PCF8575::DigitalInput val = pcf8575.digitalReadAll();
if (val.p0==HIGH) Serial.println("KEY0 PRESSED");
if (val.p1==HIGH) Serial.println("KEY1 PRESSED");
if (val.p2==HIGH) Serial.println("KEY2 PRESSED");
if (val.p3==HIGH) Serial.println("KEY3 PRESSED");
if (val.p4==HIGH) Serial.println("KEY4 PRESSED");
if (val.p5==HIGH) Serial.println("KEY5 PRESSED");
if (val.p6==HIGH) Serial.println("KEY6 PRESSED");
if (val.p7==HIGH) Serial.println("KEY7 PRESSED");
if (val.p8==HIGH) Serial.println("KEY8 PRESSED");
if (val.p9==HIGH) Serial.println("KEY9 PRESSED");
if (val.p10==HIGH) Serial.println("KEY10 PRESSED");
if (val.p11==HIGH) Serial.println("KEY11 PRESSED");
if (val.p12==HIGH) Serial.println("KEY12 PRESSED");
if (val.p13==HIGH) Serial.println("KEY13 PRESSED");
if (val.p14==HIGH) Serial.println("KEY14 PRESSED");
if (val.p15==HIGH) Serial.println("KEY15 PRESSED");
keyPressed= false;
}
}

View File

@@ -0,0 +1,28 @@
/*
KeyPressed on PIN1
by Mischianti Renzo <http://www.mischianti.org>
https://www.mischianti.org/2019/01/02/pcf8575-i2c-digital-i-o-expander-fast-easy-usage/
*/
#include "Arduino.h"
#include "PCF8575.h"
// Set i2c address
PCF8575 pcf8575(0x20);
unsigned long timeElapsed;
void setup()
{
Serial.begin(115200);
pcf8575.pinMode(P1, INPUT);
pcf8575.begin();
}
void loop()
{
uint8_t val = pcf8575.digitalRead(P1);
if (val==HIGH) Serial.println("KEY PRESSED");
delay(50);
}

View File

@@ -0,0 +1,35 @@
/*
KeyPressed async
by Mischianti Renzo <http://www.mischianti.org>
https://www.mischianti.org/2019/01/02/pcf8575-i2c-digital-i-o-expander-fast-easy-usage/
*/
#include "Arduino.h"
#include "PCF8575.h"
// Set i2c address
PCF8575 pcf8575(0x20);
unsigned long timeElapsed;
void setup()
{
Serial.begin(115200);
pcf8575.pinMode(P1, INPUT);
pcf8575.begin();
timeElapsed = millis();
}
void loop()
{
// Read and store on buffer all input (pinMode) that are going HIGHT
pcf8575.readBuffer();
if (millis()>timeElapsed+2000){
// read value on buffer than reset value for that pin
uint8_t val = pcf8575.digitalRead(P1);
if (val==HIGH) Serial.println("KEY PRESSED STORED ON BUFFER, NOW READED AND RESETTED.");
timeElapsed = millis();
}
}

View File

@@ -0,0 +1,46 @@
/*
KeyPressed with interrupt
by Mischianti Renzo <http://www.mischianti.org>
https://www.mischianti.org/2019/01/02/pcf8575-i2c-digital-i-o-expander-fast-easy-usage/
*/
#include "Arduino.h"
#include "PCF8575.h"
// For arduino uno only pin 1 and 2 are interrupted
#define ARDUINO_UNO_INTERRUPTED_PIN 2
// Function interrupt
void keyPressedOnPCF8575();
// Set i2c address
PCF8575 pcf8575(0x39, ARDUINO_UNO_INTERRUPTED_PIN, keyPressedOnPCF8575);
unsigned long timeElapsed;
void setup()
{
Serial.begin(115200);
pcf8575.pinMode(P1, INPUT);
pcf8575.begin();
timeElapsed = millis();
}
bool keyPressed = false;
void loop()
{
if (keyPressed){
uint8_t val = pcf8575.digitalRead(P1);
Serial.print("READ VALUE FROM PCF ");
Serial.println(val);
keyPressed= false;
}
}
void keyPressedOnPCF8575(){
// Interrupt called (No Serial no read no wire in this function, and DEBUG disabled on PCF library)
keyPressed = true;
}

View File

@@ -0,0 +1,66 @@
#include "Arduino.h"
/*
* PCF8575 GPIO Port Expand
* Blink all led
* by Mischianti Renzo <http://www.mischianti.org>
*
* https://www.mischianti.org/2019/01/02/pcf8575-i2c-digital-i-o-expander-fast-easy-usage/
*
*
* PCF8575 ----- Esp32
* A0 ----- GRD
* A1 ----- GRD
* A2 ----- GRD
* VSS ----- GRD
* VDD ----- 5V/3.3V
* SDA ----- 21
* SCL ----- 22
*
* P0 ----------------- LED0
* P1 ----------------- LED1
* P2 ----------------- LED2
* P3 ----------------- LED3
* P4 ----------------- LED4
* P5 ----------------- LED5
* P6 ----------------- LED6
* P7 ----------------- LED7
*
*/
#include "Arduino.h"
#include "PCF8575.h" // https://github.com/xreef/PCF8575_library
// Instantiate Wire for generic use at 400kHz
TwoWire I2Cone = TwoWire(0);
// Instantiate Wire for generic use at 100kHz
TwoWire I2Ctwo = TwoWire(1);
// Set i2c address
PCF8575 pcf8575(&I2Ctwo, 0x20);
// PCF8575 pcf8575(&I2Ctwo, 0x20, 21, 22);
// PCF8575(TwoWire *pWire, uint8_t address, uint8_t interruptPin, void (*interruptFunction)() );
// PCF8575(TwoWire *pWire, uint8_t address, uint8_t sda, uint8_t scl, uint8_t interruptPin, void (*interruptFunction)());
void setup()
{
Serial.begin(112560);
I2Cone.begin(16,17,400000); // SDA pin 16, SCL pin 17, 400kHz frequency
// Set pinMode to OUTPUT
for(int i=0;i<8;i++) {
pcf8575.pinMode(i, OUTPUT);
}
pcf8575.begin();
}
void loop()
{
static int pin = 0;
pcf8575.digitalWrite(pin, HIGH);
delay(400);
pcf8575.digitalWrite(pin, LOW);
delay(400);
pin++;
if (pin > 7) pin = 0;
}

View File

@@ -0,0 +1,59 @@
/*
* PCF8575 GPIO Port Expand
* http://nopnop2002.webcrow.jp/WeMos/WeMos-25.html
*
* PCF8575 ----- WeMos
* A0 ----- GRD
* A1 ----- GRD
* A2 ----- GRD
* VSS ----- GRD
* VDD ----- 5V/3.3V
* SDA ----- GPIO_4(PullUp)
* SCL ----- GPIO_5(PullUp)
*
* P0 ----------------- LED0
* P1 ----------------- LED1
* P2 ----------------- LED2
* P3 ----------------- LED3
* P4 ----------------- LED4
* P5 ----------------- LED5
* P6 ----------------- LED6
* P7 ----------------- LED7
* P8 ----------------- LED8
* P9 ----------------- LED9
* P10 ----------------- LED10
* P11 ----------------- LED11
* P12 ----------------- LED12
* P13 ----------------- LED13
* P14 ----------------- LED14
* P15 ----------------- LED15
*
*/
#include "Arduino.h"
#include "PCF8575.h" // https://github.com/xreef/PCF8575_library
// Set i2c address
PCF8575 pcf8575(0x20);
void setup()
{
Serial.begin(9600);
// Set pinMode to OUTPUT
for(int i=0;i<16;i++) {
pcf8575.pinMode(i, OUTPUT);
}
pcf8575.begin();
}
void loop()
{
static int pin = 0;
pcf8575.digitalWrite(pin, HIGH);
delay(1000);
pcf8575.digitalWrite(pin, LOW);
delay(1000);
pin++;
if (pin > 15) pin = 0;
}

View File

@@ -0,0 +1,63 @@
/*
* PCF8575 GPIO Port Expand
* Inverted led test: all led is connected with anodo to the IC
*
* PCF8575 ----- WeMos
* A0 ----- GRD
* A1 ----- GRD
* A2 ----- GRD
* VSS ----- GRD
* VDD ----- 5V/3.3V
* SDA ----- GPIO_4(PullUp)
* SCL ----- GPIO_5(PullUp)
*
* P0 ----------------- LED0
* P1 ----------------- LED1
* P2 ----------------- LED2
* P3 ----------------- LED3
* P4 ----------------- LED4
* P5 ----------------- LED5
* P6 ----------------- LED6
* P7 ----------------- LED7
* P8 ----------------- LED8
* P9 ----------------- LED9
* P10 ----------------- LED10
* P11 ----------------- LED11
* P12 ----------------- LED12
* P13 ----------------- LED13
* P14 ----------------- LED14
* P15 ----------------- LED15
*
*/
#include "Arduino.h"
#include "PCF8575.h" // https://github.com/xreef/PCF8575_library
// Set i2c address
PCF8575 pcf8575(0x20);
void setup()
{
Serial.begin(9600);
// Set pinMode to OUTPUT
for(int i=0;i<16;i++) {
pcf8575.pinMode(i, OUTPUT);
}
for(int i=0;i<16;i++) {
pcf8575.digitalWrite(i, HIGH);
}
pcf8575.begin();
}
void loop()
{
static int pin = 0;
pcf8575.digitalWrite(pin, LOW);
delay(1000);
pcf8575.digitalWrite(pin, HIGH);
delay(1000);
pin++;
if (pin > 15) pin = 0;
}

View File

@@ -0,0 +1,56 @@
/*
Read all data after interrupt
by Mischianti Renzo <http://www.mischianti.org>
https://www.mischianti.org/2019/01/02/pcf8575-i2c-digital-i-o-expander-fast-easy-usage/
*/
#include "Arduino.h"
#include "PCF8575.h"
// For arduino uno only pin 1 and 2 are interrupted
#define ARDUINO_UNO_INTERRUPTED_PIN 2
// Function interrupt
void keyChangedOnPCF8575();
// Set i2c address
PCF8575 pcf8575(0x39, ARDUINO_UNO_INTERRUPTED_PIN, keyChangedOnPCF8575);
unsigned long timeElapsed;
void setup()
{
Serial.begin(115200);
pcf8575.pinMode(P0, INPUT);
pcf8575.pinMode(P1, INPUT);
pcf8575.pinMode(P2, INPUT);
pcf8575.pinMode(P3, INPUT);
pcf8575.begin();
Serial.println("START");
timeElapsed = millis();
}
bool keyChanged = false;
void loop()
{
if (keyChanged){
PCF8575::DigitalInput di = pcf8575.digitalReadAll();
Serial.print("READ VALUE FROM PCF P1: ");
Serial.print(di.p0);
Serial.print(" - ");
Serial.print(di.p1);
Serial.print(" - ");
Serial.print(di.p2);
Serial.print(" - ");
Serial.println(di.p3);
// delay(5);
keyChanged= false;
}
}
void keyChangedOnPCF8575(){
// Interrupt called (No Serial no read no wire in this function, and DEBUG disabled on PCF library)
keyChanged = true;
}

View File

@@ -0,0 +1,54 @@
/*
KeyPressed with interrupt in LOW_MEMORY mode
by Mischianti Renzo <http://www.mischianti.org>
https://www.mischianti.org/2019/01/02/pcf8575-i2c-digital-i-o-expander-fast-easy-usage/
*/
#include "Arduino.h"
#include "PCF8575.h"
// To use in low memory mode and prevent use of 7byte you must decomment the line
// #define PCF8575_LOW_MEMORY
// in the library
// For arduino uno only pin 1 and 2 are interrupted
#define ARDUINO_UNO_INTERRUPTED_PIN 2
// Function interrupt
void keyChangedOnPCF8575();
// Set i2c address
PCF8575 pcf8575(0x20, ARDUINO_UNO_INTERRUPTED_PIN, keyChangedOnPCF8575);
unsigned long timeElapsed;
void setup()
{
Serial.begin(115200);
pcf8575.pinMode(P0, INPUT);
pcf8575.pinMode(P1, INPUT);
pcf8575.pinMode(P2, INPUT);
pcf8575.pinMode(P3, INPUT);
pcf8575.begin();
Serial.println("START");
timeElapsed = millis();
}
bool keyChanged = false;
void loop()
{
if (keyChanged){
byte di = pcf8575.digitalReadAll();
Serial.print("READ VALUE FROM PCF: ");
Serial.println(di, BIN);
// delay(5);
keyChanged= false;
}
}
void keyChangedOnPCF8575(){
// Interrupt called (No Serial no read no wire in this function, and DEBUG disabled on PCF library)
keyChanged = true;
}