Next question I need to monitor voltage for my fuel level is this the correct way to do it ?

thanks again
adafruit_support_bill wrote:That circuit will read 5v all the time. You need a resistor between the analog pin and 5v. That will form a variable resistor divider - with Vout changing with tank level.
Since the resistance range of the sensor is pretty low, you will want a large enough value to limit the current. A 1/4w 320 ohm resistor will limit the current to about 15mA. Your Vout will range from about 150mv to 1.125v . To get better resolution on your readings you can use the Arduino's internal 1.1v reference:
https://www.arduino.cc/en/Reference/AnalogReference
#include <SPI.h>
#include "Adafruit_FRAM_SPI.h"
uint8_t FRAM_CS = 10;
uint8_t FRAM_SCK= 13;
uint8_t FRAM_MISO = 12;
uint8_t FRAM_MOSI = 11;
//Or use software SPI, any pins!
Adafruit_FRAM_SPI fram = Adafruit_FRAM_SPI(FRAM_SCK, FRAM_MISO, FRAM_MOSI, FRAM_CS);
uint16_t addr = 0;
long myValue_mi00 = 12345681.25;
void setup(void) {
Serial.begin(9600);
// Read the starting odometer readin from FRAM and print to monitor for testing
uint8_t test = fram.read8(0x0);
Serial.print("Odometer Reading "); Serial.print(myValue_mi00); Serial.println(" Miles");
long long myValue_mi00;
const int FRAM_ADDRESS = 0x0;
for(int i = 0; i<sizeof(myValue_mi00); i++) {
((byte *)&myValue_mi00)[i] = fram.read8(FRAM_ADDRESS + i);
}
fram.writeEnable(true);
for(int i = 0; i<sizeof(myValue_mi00); i++) {
fram.write8(FRAM_ADDRESS + i, ((byte *)&myValue_mi00)[i]);
}
fram.writeEnable(false);
}
void loop(void) {
}
int analogPin = 3;
int fuellevel = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
fuellevel = analogRead(analogPin);
fuellevel = map(500, 1024, 1, 99);
Serial.println(fuellevel);
}
fuellevel = map(500, 1024, 1, 99);
fuellevel = map(fuellevel, 500, 1024, 1, 99);
Blue_Ice wrote:I'll give it a shot and try and capture the readings...
I see now I missed part of the map. and Im sure i missed it on the code I uploaded to the uno (btw it does compile with no errors)
Seems i might want to write it like such
- Code: Select all | TOGGLE FULL SIZE
fuellevel = map(fuellevel, 710, 110, 1, 99);
or am I not understanding this correctly.