I have been working with the Audrino Uno program on a project using weight sensors that triggers a relay. I can get the relay to turn on and off just fine, but I have a problem with setting the relay to trigger at a specific weight. I want to be able to adjust this specific weight if/when I choose to do so.
I have some Force Sensitive Resistors (Square) and these can handle 100g-10kg. I am new to the coding community, but I have been doing electrical work for 40+ years, so I know how to set up the board, but I think I'm having trouble with the code I wrote.
The following is my code:
void setup() {
Serial.begin(9600);
}
void loop() {
pinMode(9,OUTPUT);
int sensorValue=analogRead(A0);
float voltage=sensorValue*(5.0/1023);
Serial.println(voltage);
digitalWrite(9,HIGH);
delay(sensorValue);
if (voltage>=10.00)
//digitalWrite(9,HIGH)
{
pinMode(9,HIGH);
}
Is there a library I need, or something else to add to my code, to specify how I want my project to turn on only when the weight reaches 10.4 lbs. (5 kg) or above?
WOW!!!!! You bet it does! Can't thank you more - or can I? This is going to make this project work beautifully! Where can I send a thank you gift? I cannot believe I've worked on this so long, and you fixed it in seconds! Thank you, thank you, thank you!
I am just a hobby coder. If you spend some time with the examples that come with the IDE, you can do the same in a few weeks. Thanking people is usually done by adding a karma point.
Leo..