First of all this is my first time on Arduino Forums and it is only few weeks since i started to learn about Arduino programming
.
So i wanted to improve my skills with this simple project about a small weighing scale with a relay output ( LED or a Buzzer .....etc ) .
Components are :
1- LCD 2 X 16
2- Keypad 4 X 4
3- Arduino Mega 2560
4- 5 KG Load Cell
5- 5 V Output Relay
6- HX711 Amp
7- Push button ( pin # 10 )
Lets say i want to enter 2 variables( Weight range ) with my 4x4 keypad and it is displayed on LCD 2 x 16 and if
press # it confirms or * to reset inputs
assuming that the two variables are X =195 grams and Y = 200 grams so if i put something more than
200 grams or less than 195 grams on the load cell i get an output on my relay
The Problem is i can't figure out how to write this a code for a way to make my LCD and Keypad to ask the user to
enter the 2 variables and then the program is executed.
The Code i am trying to use it is not completed yet and still missing some lines
#include "HX711.h"
#include <LiquidCrystal.h>
#include <Keypad.h>
#define CLK A0
#define DOUT A1
#define calibration_factor 1000.0
HX711 scale;
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1','2','3','A'} ,
{'4','5','6','B'} ,
{'7','8','9','C'} ,
{'*','0','#','D'}
};
byte rowPins[ROWS] = { 9,8,7,6 };
byte colPins[COLS] = { 5,4,3,2, };
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
LiquidCrystal lcd(13, 12,45,46,47,48);
int relayPin=33;
int resetPin = 10;
float weight;
void setup() {
lcd.begin(16, 2);
lcd.print("Initializing...");
delay(100);
pinMode(resetPin, INPUT);
scale.begin(DOUT, CLK);
scale.set_scale(calibration_factor);
scale.tare(); // reset weight on scale to 0 grams
lcd.clear();
}
void loop() {
weight = scale.get_units();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Weight:");
lcd.setCursor(0, 1);
lcd.print(weight);
lcd.print(" gm");
if(digitalRead(resetPin) == 0){
scale.tare(); // reset weight on scale to 0 grams
}
if(weight<195){digitalWrite(relayPin,HIGH);}
else{digitalWrite(relayPin,LOW);}
if(weight>200){digitalWrite(relayPin,HIGH);}
else{digitalWrite(relayPin,LOW);}
}
To be honest i searched on google for any sources or topics with the same project before posting this but didn't help