Help with Programming

Hello all I'm working on a oil tank level system using the ultrasonic sensor.
I have it working but I can't figure out how to do the inch to gallon conversion.
I have tried to search for it but no luck any help would be great thanks here's my code.

#include "Ultrasonic.h"
#include <LiquidCrystal.h>

#define TRIG_PIN 10
#define ECHO_PIN 8
#define buzzer_pin 9
int sensorPin = 8;
int buzzerpin = 9;
int sensorMin = 5 ;
int sensorMax = 24 ;
int sensorValue = 0 ;

Ultrasonic OurModule(TRIG_PIN, ECHO_PIN);

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
pinMode(buzzerpin, OUTPUT);
float h;
lcd.begin(16, 2);
lcd.setCursor(3, 0);
lcd.print(" Oil Tank ");
lcd.setCursor(0, 1);
lcd.print(" Level Display ");
delay(5000);
lcd.setCursor(6, 8);

}

void loop()

{
int Gallons;
lcd.clear();
lcd.setCursor(5, 0);
lcd.print(OurModule.Ranging(INC));
lcd.print("Gall");
lcd.setCursor(0,1);
lcd.print(" Oil Tank Level ");
delay(2000);
sensorValue = (OurModule.Ranging(INC));
if (sensorValue < sensorMin){
digitalWrite(buzzerpin, HIGH);
delay(60);
digitalWrite(buzzerpin,LOW);
delay(10);
lcd.clear();
lcd.setCursor(4,0);
lcd.print ("Warning");
lcd.setCursor(6,8);
lcd.print ("Full");
delay(5000);

}
else {

lcd.setCursor(6,8);
lcd.print(" Oil Tank Level ");

}}

It depends upon the shape of your tank. It sounds like you are measuring the level of the oil in the tank (in inches) and you want to convert this to a volume. Right? Hopefully you see that volume will be different if the tank is a cylinder, does/does not have rounded bottom, or is a cube, etc.

--
The Rugged Motor Driver: two H-bridges, more power than an L298, fully protected

Yes your right I want to convert to volume it is a square tank .
It doesn't have to be very accurate I just need a rough Idea of the tank level.

OK...the volume of a square tank is LWH where L is length, W is width, H is height. It looks like you are measuring H. You just need to know what L and W are.

--
The Flexible MIDI Shield: MIDI IN/OUT, stacking headers, your choice of I/O pins

It will be hard to help you. Here my best. You have to know this : 1 " = ? gallons. or 1 m = ? litres or 1 mm = ? litres or 1 cm = ? litres. Here an another one : 1 inch = ? cube inches --> in^3 and 1 cube inche to gallons...

You need that info : 1 " = ? gallons. If you found that info, just do : gallons = X inches * ? galons/inches.

Ok thanks I can figure that out but I don't know how to make the software conversion.
I can only get it to display inches It sete's off the alarm just fine .

That is easy.

Find : 1 inches = ? gallons of your tank.

For example : 1 inch = 4 galons.

in code :

const float gallonperinches = 4;  // Constant for you tank

float distances; // your measurement

float gallons;

gallons = distances * galonperinches;

And simply display the gallons data. And make sure you know to display floats numbers.

I have used this method, describe here, for different tanks with different shapes.

You start by putting some small know amount of water in the tank and then note down the water lvl high.
Then put a little more and note down, and continue until you have enough data or the tank is full.

The more often you make a note on the amount and lvl high, the more accurate does your end result get

Then you take you data and plot it in excel or equivalent and make a graph. Now make a trend line of that graph. Now excel is able to tell you the equation for that trend line.

That equation can be programmed into the arduino.

Example.
Data from measuring.
water lvl 0 0,1 0,2 0,3 0,4 0,5 0,6 0,7 0,8 0,9 1 1,1 1,2 1,3 1,4 1,5
amount 0 0,1 0,15 0,3 0,4 0,5 0,8 1 1,1 1,5 1,8 2 2,5 3 4 5

The equation from excel is Y=0,1x

Offcause if you skip the trend line and just make a equation off your originally graph, you well have a more accurate result - however, the equations can get more complicated and so with the programming.

Thank you for your help guys I need to learn more about programing
and try this again Do you guys know any good guides ?
I just got started in arduino and the programing is a little confusing anyway thanks guys.

I just got started in arduino and the programing is a little confusing

You're doing better than most newcomers, then. Most find the programming very confusing.