Hello,
I need an ARDUINO programme part made for the buzzer alert. I am a beginner to the coding world. Much appreciate your help.
Project: Making a digital loadcell weight scale with buzzer ( to alert when passing 50g). I have made the load cell scale and now the weight values are displaying. But I need help to program the buzzer alert.
Components needed: Arduino Uno, HX711 board, LCD with I2C, Buzzer
Objective: Please check the attached schematic diagram and the code and write a code to programe the buzzer to alert when the weight is passing 50 g.
Note: code is a mixture of codes I found on the internet combined together to make it work, so it will look confusing. Do not hesitate to erase unnecessary parts and add as necessary.
Note : I only need the buzzer alert part made. other parts i got covered. All the code and schematic diagram credits goes to the original owner.
Thank you very much!
#include <HX711.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
int IN1 = A0;
int IN2 = A1;
int over_val;
int data;
int g_weight;
int Weight;
const int buzzer = 13;
#include <HX711.h>
#define DOUT 3
#define CLK 2
HX711 scale(DOUT, CLK);
float calibration_factor = 2125; //-7050 worked for my 440lb max scale setup
float units;
float ounces;
void setup() {
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(20, 4);
lcd.setCursor(0, 0);
lcd.print("HX711 calibration");
Serial.println("HX711 calibration sketch");
Serial.println("Remove all weight from scale");
Serial.println("After readings begin, place known weight on scale");
Serial.println("Press + or a to increase calibration factor");
Serial.println("Press - or z to decrease calibration factor");
scale.set_scale();
scale.tare(); //Reset the scale to 0
long zero_factor = scale.read_average(); //Get a baseline reading
Serial.print("Zero factor: "); //This can be used to remove the need to tare the scale. Useful in permanent scale projects.
Serial.println(zero_factor);
}
void loop() {
scale.set_scale(calibration_factor); //Adjust to this calibration factor
Serial.print("Reading: ");
units = scale.get_units(), 10;
if (units < 0) {
units = 0.00;
}
ounces = units * 0.035274;
Serial.print(units);
Serial.print(" grams");
Serial.print(" calibration_factor: ");
Serial.print(calibration_factor);
Serial.println();
lcd.setCursor(0, 1);
lcd.print("Grams: ");
lcd.print(units);
lcd.setCursor(0, 2);
lcd.print("Ounce: ");
lcd.print(ounces);
lcd.setCursor(0, 3);
lcd.print("Calbr: ");
lcd.print(calibration_factor);
if(Serial.available())
{
char temp = Serial.read();
if(temp == '+' || temp == 'a')
calibration_factor += 1;
else if(temp == '-' || temp == 'z')
calibration_factor -= 1;
}
}
