I thought I responded to both, my bad.
When I bring u the serial monitor it counts to 5 and prints" Box is full" and right below that is prints "Full boxes". My logic is that after 5 it will add 1 to the box.
When while runs and the count == 5 it increments to 6 at the end. Then in the if statement You test if count == 5, but it is 6 now..... the if will not execute.
This Is what I ended up with. Now I need to figure out how to get it to restart the loop after the first pallet is filled.
int productC;
int boxC;
int palletC;
int T = 300;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
productC = 0;
while (productC <= 5) {
Serial.println(productC);
productC = productC + 1;
delay(T);
}
Serial.println("Box is full");
Serial.println();
do {
boxC = boxC + 1;
} while (productC ==5);
Serial.print(boxC);
Serial.println(" Full boxes");
Serial.println( );
delay(T);
do {
palletC = palletC + 1;
} while (boxC == 6);
Serial.print(palletC);
Serial.print(" Boxes on pallet");
Serial.println( );
Serial.println( );
delay(T);
if (palletC == 6) {
Serial.println("Pallet is full");
delay(T);
}
}
You should post code by using code-tags. There are two simple ways to do this.
First way is to click on the code tags icon at the top of the posting window
Another wasy is to use an automatic function for doing this in the Arduino-IDE.
Three steps
1)press Ctrl-T for autoformatting your code
2)do a rightclick with the mouse and choose "copy for forum"
3)paste clipboard into write-window of a posting