-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Subject of the issue
Examples are missing call to .poll() function in setup() which is why these examples are failing to produce data.
Your workbench
- OSX Ventura, Arduino IDE 2.03, target is the Speed Xiao
- Two 1-axis ADSs wired to 3v3, GND, SDA and SCL with pull-up resistors on SDA and SCL (10k?)
- Power from the Xiao @ 3v3
Steps to reproduce
One needs to add a call to .poll() function for each instance of ADS. Current examples are missing this. So this is the fix:
#include <Wire.h>
#include "SparkFun_Displacement_Sensor_Arduino_Library.h"
ADS myFlexSensor; //Create instance of the Angular Displacement Sensor (ADS) class
ADS myFlexSensor2; //Create instance of the Angular Displacement Sensor (ADS) class
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("SparkFun Displacement Sensor Example");
Wire.begin();
if (myFlexSensor.begin() == false) {
Serial.println(F("No sensor detected. Check wiring. Freezing..."));
while (1)
;
}
if (myFlexSensor2.begin(0x15) == false) {
Serial.println(F("No sensor detected. Check wiring. Freezing..."));
while (1)
;
}
myFlexSensor.poll(); // <--- add a call to .poll function in the library
myFlexSensor2.poll(); //<--- add a call to .poll function in the library
}
void loop() {
if (myFlexSensor.available() == true) {
Serial.print("#1: ");
Serial.print(myFlexSensor.getX());
Serial.println();
} else {
Serial.println("non available");
}
if (myFlexSensor2.available() == true) {
Serial.print("#2: ");
Serial.print(myFlexSensor2.getX());
Serial.println();
} else {
Serial.println("non available");
}
delay(10);
}
Expected behaviour
The examples should be clear and work 'out of the box.'
Actual behaviour
The examples fail to poll the sensor(s) as a call to .poll() is not included.
Metadata
Metadata
Assignees
Labels
No labels