I’ve been able to use my Qwiic buttons compling under PlatformIO. And I’ve been able to scan I2C addresses under Arduino IDE, but haven’t been able to get the stock examples going. Code that I’ve been trying follows. Added the definition of SDA and SCL as they were wrong with my Sparkfun Thing Plus. As mentioned code for a scanner runs under Arduino IDE but Sparkfun QwiicButon doesn’t. Here’s my code:
/******************************************************************************
Checks whether the button is pressed, and then prints its status over serial!
Fischer Moseley @ SparkFun Electronics
Original Creation Date: June 28, 2019
This code is Lemonadeware; if you see me (or any other SparkFun employee) at the
local, and you've found our code helpful, please buy us a round!
Hardware Connections:
Attach the Qwiic Shield to your Arduino/Photon/ESP32 or other
Plug the button into the shield
Print it to the serial monitor at 115200 baud.
Distributed as-is; no warranty is given.
******************************************************************************/
//For this example to work, you must daisy chain together two Qwiic buttons with different addresses.
//To change the address of a Qwiic button, please visit example 6
#include <arduino.h>
#include "SparkFun_Qwiic_Button.h"
//#include "wire.h"
QwiicButton button1;
QwiicButton button2;
void setup() {
Serial.begin(115200);
Serial.println("Qwiic button examples");
//modified from example
const int SCLpin = 22;
const int SDApin = 23;
Serial.println("\n*************\nSDA = "+String(SDA));
Serial.println("SCL = "+String(SCL));
Serial.println("SDA Pin = "+String(SDApin));
Serial.println("SCL Pin = "+String(SCLpin));
Wire.begin(SDApin, SCLpin);
//check if the buttons will acknowledge over I2C
//connect to Qwiic button at address 0x5B
if (button1.begin(0x67) == false){
Serial.println("Button 1 did not acknowledge! Freezing.");
while(1);
}
}
void loop() {
//check if button 1 is pressed, and tell us if it is!
if (button1.isPressed() == true) {
Serial.println("Button 1 is pressed!");
while (button1.isPressed() == true)
delay(10); //wait for user to stop pressing
Serial.println("Button 1 is not pressed.");
}
//check if button 2 is pressed, and tell us if it is!
if (button2.isPressed() == true){
Serial.println("Button 2 is pressed!");
while (button2.isPressed() == true)
delay(10); //wait for user to stop pressing
Serial.println("Button 2 is not pressed.");
}
delay(20); //Don't hammer too hard on the I2C bus.
}