/*
--------------------------------------------
-------- Begin Initialise Variables --------
--------------------------------------------
*/
//STAGE #1
//define pins
int Hall = A0;
int Tran = 2;
int Sole = 4;
float Pendulum = 0.30;
//Sensor readings
/*--------------------------------------------
-------- End Initialise Variables ----------
--------------------------------------------
*/
/*
----------------------------------
-------- Begin Setup Loop --------
----------------------------------
*/
void setup()
{
// initialize serial communication at 115200 bits per second.
Serial.begin(9600);
//STAGE 2 - pin modes
pinMode(Hall, INPUT);
pinMode(Sole, OUTPUT);
//Control solenoid
digitalWrite(Sole, LOW);
digitalWrite(Sole, HIGH);
delay(1000);
}
/*
-------------------------------
------- End Setup Loop --------
-------------------------------
*/
/*
----------------------------------
-------- Begin Main Loop ---------
----------------------------------
*/
//STAGE 3 - the main loop
void loop()
{
// variables for timing
unsigned long startTime = 0;
unsigned long currentTime;
unsigned long elapsedTime;
int HallValue;
//get start time
Serial.print(startTime);
do {
//read Hall effects sensor
HallValue = analogRead(Hall);
//get current time
currentTime = millis();
//calc elapsed time in milliseconds
unsigned long elapsedTime(unsigned long currentTime) {
float a = 1.1;
return (currentTime - a);
}
//Print data back to the computer
Serial.print(elapsedTime);
Serial.print(",");
Serial.print(HallValue);
Serial.print("\n");
} while (elapsedTime >= 10000);
//STAGE 5 - calculate Gravity...
//average_period = something here;
if ( (A >= value_X) && (B < value_Y) ) {
//evaluate gravity
//g = your calculation here: use the sq() and PI
//STAGE 5b - print your answer...
Serial.print("gravity = ");
delay(10000); //wait for 10 seconds - LEAVE THIS FOR RELOAD TO WORK PROPERLY!
}
/*
----------------------------------
--------- End Main Loop ----------
----------------------------------
*/