Hall Effect Sensor Display

To Whom It May Concern,

Currently I am trying to create a code to display linear displacement measurements of a electromagnetic piston with the hall effect sensor in real time on a graph. This is the code we have so far. I am not entirely sure whether I am taking the right approach. Any insight would be greatly appreciated.

Thank You!


int TOMILLIGAUSS = 977;
int NOFIELD = 507;

const unsigned long hallInterval = 200;

unsigned long hallTimer = 0;

void setup() {
hallTimer = millis();
Serial.begin(9600);

}

void DoMeasurement()
{

//*********************** measure magnetic field of hall effect sensor 1***************************
int raw1 = analogRead(0); // Range : 0..1024

// Uncomment this to get a raw reading for calibration of no-field point
//Serial.print("Raw reading: ");
//Serial.println(raw);

long compensated1 = raw1 - NOFIELD; // adjust relative to no applied field
long gauss1 = compensated1 * TOMILLIGAUSS; // 1000; // adjust scale to Gauss

//Serial.print("1 = ");
Serial.println(raw1);
//Serial.println(" milliGauss ");
//Hall effect sensor 2**

int raw2 = analogRead(1);

long compensated2 = raw2 - NOFIELD; // adjust relative to no applied field
long gauss2 = compensated2 * TOMILLIGAUSS; // 1000; // adjust scale to Gauss

//Serial.print("2 = ");
Serial.println(raw2);
//Serial.println(" milliGauss ");
//***Hall effect sensor 3

int raw3 = analogRead(2);

long compensated3 = raw3 - NOFIELD; // adjust relative to no applied field
long gauss3 = compensated3 * TOMILLIGAUSS; // 1000; // adjust scale to Gauss

//Serial.print("3 = ");
Serial.println(raw3);
//Serial.println(" milliGauss ");

}

void loop() {
if( (millis() - hallTimer) >= hallInterval) {
DoMeasurement();
hallTimer = millis();
}
}

You have posted code without using code tags. This creates certain problems and obstacles for other forum members. The code tags make the code look

like this

when posting source code files. It makes it easier to read, and can be copied with a single mouse click.
If you have already posted without using code tags, open your message and select "modify" from the pull down menu labelled, "More", at the lower left corner of the message. Highlight your code by selecting it (it turns blue), and then click on the "</>" icon at the upper left hand corner. Click on the "Save" button. Code tags can also be inserted manually in the forum text using the [code] and [/code] metatags.

When you are finished that, please read these two posts:

How to use this forum - please read.
and
Read this before posting a programming question ...

The code you posted has a bunch of useless stuff happening in DoMeasurement(). What do you want to graph? Where?