Trying to make change in weight readings cause a decrease in computer volume

Hello! Im making a project where if your weight shifts on a load cell scale, it makes the audio in my computer decrease.

So far, Ive built a working, reading scale with 4 load cells hooked up to my Arduino Rev3 Uno. Im trying to translate those readings through python to have a reading decrease the volume on my macbook. (At this point, I am at least trying to get any weight to decrease the volume, and then hoping I can work from there to alter it to any change in weight reading..)

Thing is, I cant get the readings to trigger a VolumeDown command through Arduino IDE. Heres my code so far:
#include "HX711.h"

#define calibration_factor -7050.0 //This value is obtained using the SparkFun_HX711_Calibration sketch

#define LOADCELL_DOUT_PIN 3
#define LOADCELL_SCK_PIN 2

HX711 scale;

void setup() {
Serial.begin(9600);
Serial.println("HX711 scale demo");

scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
scale.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0

float scaleValue = scale.get_units();

Serial.println("Readings:");
}

void loop() {
Serial.print("Reading: ");
Serial.print(scale.get_units(), 1); //scale.get_units() returns a float
Serial.print(" lbs"); //You can change this to kg but you'll need to refactor the calibration_factor
Serial.println();

if (scale.get_units()>10.0);
{(Serial.println("VDown"));delay (500);}

}

My thought was -- at the end, if the reading is over 10 lbs, then it will send a VDown (volume down) signal. Through python, it will then trigger my computer to decrease volume. I feel okay with the python aspect -- but it's sending a VDown signal to python with every single reading (even of 0lbs)
Any ideas? Am I using the wrong if _ statement?
New to Arduino this week. Apologies to any lengthiness or lack of clarity. Appreciate any comments.

Remove the semicolon at the end of this line. That semicolor terminates the if statement.

2 Likes

Wow. Thanks. I really appreciate you taking the time to check it over for even such a small thing.. You fixed my project!! (:

A quick trick to highlight that error is to use the Tools/auto format:

void setup() {
  // put your setup code here, to run once:
  if (false);
    Serial.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly:
}

and with Tools/Auto Format:

void setup() {
  // put your setup code here, to run once:
  if (false)
    ;
  Serial.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly:
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.