ok heres the example that adafruit put out for the feather wing joy.
Code: Select all
#include "Adafruit_seesaw.h"
Adafruit_seesaw ss;
#define BUTTON_RIGHT 6
#define BUTTON_DOWN 7
#define BUTTON_LEFT 9
#define BUTTON_UP 10
#define BUTTON_SEL 14
uint32_t button_mask = (1 << BUTTON_RIGHT) | (1 << BUTTON_DOWN) |
(1 << BUTTON_LEFT) | (1 << BUTTON_UP) | (1 << BUTTON_SEL);
#if defined(ESP8266)
#define IRQ_PIN 2
#elif defined(ESP32)
#define IRQ_PIN 14
#elif defined(NRF52)
#define IRQ_PIN 27
#elif defined(TEENSYDUINO)
#define IRQ_PIN 8
#elif defined(ARDUINO_ARCH_WICED)
#define IRQ_PIN PC5
#else
#define IRQ_PIN 5
#endif
void setup() {
Serial.begin(115200);
while(!Serial);
if(!ss.begin(0x49)){
Serial.println("ERROR!");
while(1);
}
else{
Serial.println("seesaw started");
Serial.print("version: ");
Serial.println(ss.getVersion(), HEX);
}
ss.pinModeBulk(button_mask, INPUT_PULLUP);
ss.setGPIOInterrupts(button_mask, 1);
pinMode(IRQ_PIN, INPUT);
}
int last_x = 0, last_y = 0;
void loop() {
int x = ss.analogRead(2);
int y = ss.analogRead(3);
if ( (abs(x - last_x) > 3) || (abs(y - last_y) > 3)) {
Serial.print(x); Serial.print(", "); Serial.println(y);
last_x = x;
last_y = y;
}
if(!digitalRead(IRQ_PIN)){
uint32_t buttons = ss.digitalReadBulk(button_mask);
//Serial.println(buttons, BIN);
if (! (buttons & (1 << BUTTON_RIGHT))) {
Serial.println("Button A pressed");
}
if (! (buttons & (1 << BUTTON_DOWN))) {
Serial.println("Button B pressed");
}
if (! (buttons & (1 << BUTTON_LEFT))) {
Serial.println("Button Y pressed");
}
if (! (buttons & (1 << BUTTON_UP))) {
Serial.println("Button x pressed");
}
if (! (buttons & (1 << BUTTON_SEL))) {
Serial.println("Button SEL pressed");
}
}
delay(10);
}
the seesaw library can be found here....
https://github.com/adafruit/Adafruit_Seesaw
and my board can be found here......
https://www.adafruit.com/product/3405
the example above is only for one featherwing joy but I will be using two. but two on the same bus can take up time, so I want to use two sets of i2c pins on my huzzah. SDA and SCL are set on 22 and 23. Where would these pin defines be found in the Arduino esp library.
the programs begin asks for the device address and not the pin and frequency so I need to know where to define the second set of pins and would I do a double .begin to use both i2c devices?
The huzzah32 has its sda and scl set to this.....
Code: Select all
static const uint8_t TX = 17;
static const uint8_t RX = 16;
static const uint8_t SDA = 23;
static const uint8_t SCL = 22;
static const uint8_t SS = 2;
static const uint8_t MOSI = 18;
static const uint8_t MISO = 19;
static const uint8_t SCK = 5;
so if I want to use a second set of i2c do simply say...
static const uint8_t SDA2 = pin;
static const uint8_t SCL2 = pin;