I am using pin 3 from the data sheet. 47ohm resistors. VDD=3.3v
If I pull pin 3 down to gnd with 47ohm resistor, I get ~320.
If I pull pin 3 up to VDD with 47ohm, I get ~810
If I put a divider from VDD to gnd, pin 3 is output of divider (47ohm high and low dividers) I get 512 which I expect.
But why wont pulling down to gnd read 0, or up to VDD read 1023?
Thank you for reading.
Code:
If I pull pin 3 down to gnd with 47ohm resistor, I get ~320.
If I pull pin 3 up to VDD with 47ohm, I get ~810
If I put a divider from VDD to gnd, pin 3 is output of divider (47ohm high and low dividers) I get 512 which I expect.
But why wont pulling down to gnd read 0, or up to VDD read 1023?
Thank you for reading.
Code:
Code:
#include <Wire.h>
#define pot 2 // LED1 for Configure command communication indication
#define batt_fb 3 // LED2 for READ command communication indication
#define MySerial Serial
// Constants
byte bright1 = 0x3C;
byte bright2 = 0x78;
byte bright3 = 0xFF;
// Variables
int battV = 0;
int battV1 = 0;
int battV2 = 0;
int battV3 = 0;
int battVavg = 0;
void setup() {
Wire.begin();
MySerial.begin(9600);
MySerial.println("IS323FL3238 Driver");
MySerial.println(bright1);
analogReference(VDD); //Sets up ADC reference to VDD
pinMode(batt_fb,INPUT);
// ***Initialize I2C communications:
byte error, address; // variable for scanning all addresses
int nDevices; // number of devices on circuit
MySerial.println("IS323FL3238 Control");
MySerial.println("Scanning for device I2C address...");
nDevices = 0;
for (address = 1; address < 127; address++ ) // I2C Device Address Scanning
{
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
MySerial.print("I2C device found at address 0x");
if (address < 16)
MySerial.print("0");
MySerial.print(address, HEX);
MySerial.println(" !");
nDevices++;
}
else if (error == 4)
{
MySerial.print("Unknown error at address 0x");
if (address < 16)
MySerial.print("0");
MySerial.println(address, HEX);
}
}
if (nDevices == 0)
MySerial.println("No I2C devices found\n");
else
MySerial.println("done\n");
delay(500);
}
void loop() {
battV1 = analogRead(batt_fb); //read batt_fb and store in battV
delay(10);
battV2 = analogRead(batt_fb);
delay(10);
battV3 = analogRead(batt_fb);
delay(10);
battVavg = battV1 + battV2 + battV3;
delay(10);
battV = battVavg/3;
MySerial.println("battery voltage (V):");
MySerial.println(battV);