Starting off, I am brand new to arduino and am very limited on understanding C++, but I will try to properly explain and understand whatever input you can offer me.
I currently am working on a project interfacing an arduino with a weigh scale that will then perform 3 actions based on time and the reading from the scale.
I currently have the scale rs-232 serial line converted into TTL using a MAX233 chip and have the ardunio spitting out data points into the serial monitor.
I also have relays controlled on switching pins to high or low, and button pushes starting the loop that I wish to occur.
I have a switch statement lined out for reading serial and outputting high/low values to control an LED.
So what is my problem?
I am utterly lost on taking in the scales serial output (which is something like " N 500 lb") and converting it into just the useful numeric value which is the weight on the scale and having operations go on based on the weight.
So what I am after is that when I push a button it will first check the scale and for instance make sure that the scale reads 0 (which could be N 0 lb without needing conversion, but I cant even figure out how to have a switch() line without using standard bytes), then after reading 0 it will switch relay 1 on (which is a liquid), then it will wait until the weight reaches say 1000lbs (N 1000 lb), it will then switch off relay 1 and now switch on relay 2 (mixer motor), it will then switch on relay 3 which adds a solid and stay on until a certain weight again (ex. N 1100 lb) after that is reached relay 3 shuts off. Relay 2 (mix motor) will stay on with a delay command for say 5minutes and then shutoff. Then when I push the button I want it to do it all over again without interruptions or resetting by pressing the button or anything like that.
So my main problem in getting all of this to work is to have the serial input from the scale being properly read by the arduino so in my code I can make it do what I want.
I dont really have any code to paste here simply because up until now all of these individual controls I have achieved are all separate programs, but I was using
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pins:
for (int thisPin = 2; thisPin < 7; thisPin++) {
pinMode(thisPin, OUTPUT);
}
}
void loop() {
// read the sensor:
if (Serial.available() > 0) {
int inByte = Serial.read();
// do something different depending on the character received.
// The switch statement expects single number values for each case;
// in this exmaple, though, you're using single quotes to tell
// the controller to get the ASCII value for the character. For
// example 'a' = 97, 'b' = 98, and so forth:
switch (inByte) {
case 'a':
digitalWrite(13, LOW);
Serial.println("You just turned it off idiot");
break;
case 'b':
digitalWrite(13, HIGH);
Serial.println("You turned an LED on, want a cookie?");
break;
case 'c':
digitalWrite(4, HIGH);
break;
case 'd':
digitalWrite(5, HIGH);
break;
case 'e':
digitalWrite(6, HIGH);
break;
default:
// turn all the LEDs off:
for (int thisPin = 2; thisPin < 7; thisPin++) {
digitalWrite(thisPin, LOW);
}
}
}
}
thanks in advance for any information you can offer me.