Hello!
I am having some trouble with my code, i have a three load cells setup, I wanted to start by getting a "zero" weight on all three load cells and then constantly monitor the load cell weight. but i am unable to compile the code, could someone look at my code and tell me what i am doing wrong?
Thank you
void setup()
{
// put your setup code here, to run once:
SerialUSB.begin(9600); // initialize serial communication
}
void loop()
{
int sensorValue1 = analogRead(A0); // A0 as input from loadcell 1
int sensorValue2 = analogRead(A1); // A1 as input from loadcell 2
int sensorValue3 = analogRead(A2); // A2 as input from loadcell 3
if (SerialUSB.available() == 1);
{
zero();
}
float voltage1 = sensorValue1 * (5.0 / 3420.0);
long int W1 = (voltage1/0.01);
float voltage2 = sensorValue2 * (5.0 / 3420.0);
long int W2 = (voltage2/0.01);
float voltage3 = sensorValue3 * (5.0 / 3420.0);
long int W3 = (voltage3/0.01);
int d1 = (W1 - zW1);
int d2 = (W2 - zW2);
int d3 = (W3 - zW3);
if (d1 > 10)
{
SerialUSB.println("Watch out!"):
}
if (d2 > 10)
{
SerialUSB.println("Watch Out!"):
}
if (d3 > 10)
{
SerialUSB.println("Watch Out!"):
}
if (d1 > 20)
{
SerialUSB.println("Watch Out!, Disable motor!!"):
}
if (d2 > 20)
{
SerialUSB.println("Watch Out! Disable motor!!"):
}
if (d3 > 20)
{
SerialUSB.println("Watch Out! Disable motor!!"):
}
}
void zero()
{
// aquring weight of furnace after preform staged in furnace.
int sensorValue1 = analogRead(A0); // A0 as input from loadcell 1
int sensorValue2 = analogRead(A1); // A1 as input from loadcell 2
int sensorValue3 = analogRead(A2); // A2 as input from loadcell 3
float zVoltage1 = sensorValue1 * (5.0 / 3420.0);
long int zW1 = (zVoltage1/0.01);
float zVoltage2 = sensorValue2 * (5.0 / 3420.0);
long int zW2 = (zVoltage2/0.01);
float zVoltage3 = sensorValue3 * (5.0 / 3420.0);
long int zW3 = (zVoltage3/0.01);
}
loadcell_setup.ino (1.69 KB)