change bank address

This commit is contained in:
Siwat Sirichai 2023-08-26 12:47:28 +07:00
parent 81434a39b5
commit 81f0e80f8c
3 changed files with 14 additions and 7 deletions

View File

@ -5,7 +5,7 @@ uint8_t inputBufferB;
PCF8574 inputBankA(INPUT_BANK_A_ADDRESS); PCF8574 inputBankA(INPUT_BANK_A_ADDRESS);
PCF8574 inputBankB(INPUT_BANK_B_ADDRESS); PCF8574 inputBankB(INPUT_BANK_B_ADDRESS);
Adafruit_PWMServoDriver pwmBank = Adafruit_PWMServoDriver(0x5F); Adafruit_PWMServoDriver pwmBank = Adafruit_PWMServoDriver(PWM_BANK_ADDRESS);
void ESPMega_begin() void ESPMega_begin()
{ {
@ -15,7 +15,13 @@ void ESPMega_begin()
inputBankB.begin(); inputBankB.begin();
pwmBank.begin(); pwmBank.begin();
// ESPMegaPRO v3 use the PWMBank to drive Half Bridge
// Push Pull Output is required.
pwmBank.setOutputMode(true);
#ifdef USE_INTERRUPT #ifdef USE_INTERRUPT
pinMode(INPUT_BANK_A_INTERRUPT, INPUT_PULLUP);
pinMode(INPUT_BANK_B_INTERRUPT, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(INPUT_BANK_A_INTERRUPT),refreshInputBankA,FALLING); attachInterrupt(digitalPinToInterrupt(INPUT_BANK_A_INTERRUPT),refreshInputBankA,FALLING);
attachInterrupt(digitalPinToInterrupt(INPUT_BANK_B_INTERRUPT),refreshInputBankB,FALLING); attachInterrupt(digitalPinToInterrupt(INPUT_BANK_B_INTERRUPT),refreshInputBankB,FALLING);
#endif #endif

View File

@ -7,13 +7,14 @@
#include <PCF8574.h> #include <PCF8574.h>
#define INPUT_BANK_A_ADDRESS 0x21 #define INPUT_BANK_A_ADDRESS 0x21
#define INPUT_BANK_B_ADDRESS 0x20 #define INPUT_BANK_B_ADDRESS 0x22
#define PWM_BANK_ADDRESS 0x5F
#define OUTPUT_BANK_ADDRESS 0x21 #define OUTPUT_BANK_ADDRESS 0x21
#define EEPROM_ADDRESS 0x22 #define EEPROM_ADDRESS 0x22
//#define USE_INTERRUPT //#define USE_INTERRUPT
//#define INPUT_BANK_A_INTERRUPT 35 #define INPUT_BANK_A_INTERRUPT 36
//#define INPUT_BANK_B_INTERRUPT 39 #define INPUT_BANK_B_INTERRUPT 39
/** /**
* Initiate ESPMega PRO Internal Components * Initiate ESPMega PRO Internal Components

View File

@ -6,12 +6,12 @@ void setup() {
} }
void loop() { void loop() {
if(ESPMega_digitalRead(7)) { if(ESPMega_digitalRead(11)) {
ESPMega_digitalWrite(8, HIGH); ESPMega_digitalWrite(8, HIGH);
Serial.println("7HIGH"); Serial.println("11HIGH");
} else { } else {
ESPMega_digitalWrite(8, LOW); ESPMega_digitalWrite(8, LOW);
Serial.println("7LOW"); Serial.println("11LOW");
} }
ESPMega_loop(); ESPMega_loop();
} }