Hi all, Im after some friendly advice.
i have been playing around with a project for about a week now and im wondering if im going down the wrong path.
I am using a nano with a hx711 + load cell + 16 x 2 i2c lcd it also has 2 LED's (green,red) and the goal is to turn the led to a flashing green for 5 seconds once required load is reached and when it is reached the led shoud turn solid green, but also if the pressure falls below said weight in the 5 seconds i want the board to halt or at least reset. and maybe even a count down on the lcd of 5-0 secs
reading up i went down a couple of routes once i found that delays will take over anything else. I thought millis is what i will need but so far i havent got very far with it as it seemed to interupt certain things still. (maybe i used it wrong,my coding skills are amatuer). Also looking at a few posts ive seen it is in my understanding that millis counts from the time the program starts not from a "trigger".
Before i carry on with this project am i asking too much of the nano with this?
Any advice on how to code this would be greatly appricated i have looked over alot of the posts on here but im kinda stuck in the direction to take.
ive got the code i have so far below without the millis in as i got a bit annoyed and deleted it lol (its probably not very clean but it might help) .
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F,16,2); // set the LCD address to 0x3F for a 16 chars and 2 line display
#include "HX711.h"
#define DOUT 5
#define CLK 6
int LED1 = 2;
int LED2 = 3;
HX711 scale(DOUT, CLK);
float calibration_factor = 357500; //-7050 worked for my 440lb max scale setup
float units;
float ounces;
void setup() {
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
lcd.backlight(); //open the backlight
lcd.init(); //initialize the lcd
lcd.setCursor(0, 0);
lcd.print("CALIBRATING.....");
delay(1500);
lcd.clear();
delay(500);
lcd.print("-----READY-----");
delay(1000);
lcd.clear();
scale.set_scale();
scale.tare(); //Reset the scale to 0
long zero_factor = scale.read_average(); //Get a baseline reading
}
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;
lcd.setCursor(0, 1);
lcd.print("K/G's: ");
lcd.print(units);
units = scale.get_units(), 10;
if (units < 0)
units = 0.00;
if (units <=13)digitalWrite(LED1, HIGH);
if (units >13)digitalWrite(LED1, LOW);
if (units >=13)digitalWrite(LED2, HIGH);
if (units <13)digitalWrite(LED2, LOW);
}
Thanks in advance. (sorry if this is a noob question and ive missed something)