hello everyone,
I am fairly new to arduino, and programming but i have been trying to learn so far. my problem is im working on a project and it seems ive ventured into things im not ready for . i believe ive done most of the ground work because i have tested and calibrated all of the components and have there separate functioning codes . then i decided to put them all together and make one unit . i already assembled the hardware but im having problem putting the codes together .
if any one is interested in pointing me in the right direction i would really appreciate it as i have been stuck for a couple days .
my project is level detector using load cells and a smoke and gas detector , i also have an lcd connected for displaying the current situation of the system . if your interested in seeing the code ,just message me and i will send it . thank you
Welcome to the Forum. Please read the two posts at the top of this Forum by Nick Gammon on guidelines for posting here, especially the use of code tags ("</>") when posting source code files. Also, before posting the code, use Ctrl-T in the IDE to reformat the code in a standard format, which makes it easier for us to read.
/
// ADDING HX711 AMPLIFIER CODE , ANOTHER SKETCH WAS USED TO CALIBERATE THE SCALE AND OBTAIN THE CALEBERATION FACTOR (-8360)
#include "HX711.h"
// ADDING THE LCD LIBRARY
#include <LiquidCrystal.h>
const int sensorPin= 0;
const int solenoidPin= 10;
int lpgsmoke_level;
const int calibration_factor= -8360.0; //This value is obtained using the SparkFun_HX711_Calibration sketch
const int DOUT= 3;
const int CLK= 2;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 7, 6, 5, 4);
HX711 scale(DOUT, CLK);
void setup() {
Serial.begin(115200); //sets the baud rate for data transfer in bits/second
pinMode(sensorPin, INPUT);//the smoke sensor will be an input to the arduino
pinMode(solenoidPin, OUTPUT);//the solenoid serves an output in the circuit
Serial.begin(9600);
Serial.println("HX711 scale demo");
// set up the LCD's number of columns and rows:
lcd.begin(16, 4);
// Print a message to the LCD.
lcd.print("GAS-PAL");
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
Serial.println("Readings:");
}
void loop() {
lpgsmoke_level= analogRead(sensorPin); //arduino reads the value from the sensor
Serial.println(lpgsmoke_level);//prints just for debugging purposes, to see what values the sensor is picking up
if(lpgsmoke_level > 300){ //if smoke level is greater than 300, the solenoid will go off
digitalWrite(solenoidPin, HIGH);}
Serial.print("Reading: "); // scale section starts
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();
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0,13);
// print the number of seconds since reset:
lcd.print(millis() / 10);
}
no error message , i placed all my bits of codes in one unit . then i got stuck . i need to create a small interactive menu and display my readings on the lcd
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Also in the arduino IDE select TOOLS and Auto Format, it will line your statements up to be able to see levels of your program.