Sketch needlessly pauses at startup and waits for rotary movement

For some reason my sketch just waits at a screen on the LCD with nothing but blocks on rows 1 and 3 for like 3 seconds (no doubt just normal boot time) but then stays there won't go any further until I turn my rotary knob left, then it proceeds with the code normally.

I'm sure the reason is obvious and staring me right in the face but this is someone else's code I modded and I'm a noob in the worst way, so I thought I'd throw the problem out here.

EDIT: It just dawned on me that there's a load cell circuit that's not connected at the moment, so perhaps it's waiting for that or something. Of course this only occurred to me AFTER I posted this thread and now I can't delete it and wait until I test this idea first. :frowning:

Anyway here's part of the code in question:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "HX711.h"
LiquidCrystal_I2C lcd(0x27,20,4);
HX711 scale(5, 6);
#define clk 2
#define dt 3
#define sw 4
#define in1 7
#define in2 8
#define in3 9
#define in4 10
#define in5 11
#define in6 12
#define in7 13
#define in8 14
volatile boolean TurnDetected;
volatile boolean up;
bool doonce = 0;
char screen = 0;
boolean changestate = 0;
long weight;
int pump1ml = 20;
int pump2ml = 20;
int pump3ml = 20;
int pump4ml = 20;

void isr0 () {
TurnDetected = true;
up = (digitalRead(clk) == digitalRead(dt));
}

void setup() {
lcd.init();
lcd.backlight();
pinMode(sw, INPUT_PULLUP);
pinMode(clk, INPUT);
pinMode(dt, INPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
pinMode(in5, OUTPUT);
pinMode(in6, OUTPUT);
pinMode(in7, OUTPUT);
pinMode(in8, OUTPUT);
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
digitalWrite(in5, LOW);
digitalWrite(in6, LOW);
digitalWrite(in7, LOW);
digitalWrite(in8, LOW);
attachInterrupt (0, isr0, RISING);
}

void loop() {
if (TurnDetected) {
delay(200);
doonce = 0;
if (changestate == 0) {
if (up) {
screen++;
if (screen > 4) {
screen = 4;
}
}
else {
screen = screen - 1;
if (screen < 0) {
screen = 0;
}
}
}
else {
if (up) {
switch (screen) {
case 0: pump1ml = pump1ml + 10;
break;
case 1: pump2ml = pump2ml + 10;
break;
case 2: pump3ml = pump3ml + 10;
break;
case 3: pump4ml = pump4ml + 10;
break;
}
}
else {
switch (screen) {
case 0: pump1ml = pump1ml - 10;
break;
case 1: pump2ml = pump2ml - 10;
break;
case 2: pump3ml = pump3ml - 10;
break;
case 3: pump4ml = pump4ml - 10;
break;
}
}
}
TurnDetected = false;
}

if (digitalRead(sw) == LOW) {
delay(200);
changestate = !changestate;
doonce = 0;
}

I don't see where that code tells the screen to do anything until TurnDetected is true. So it looks like it is doing what you coded it to do.

Can you please format your code and put it in code tags to make it easier to read and work with. Please read the "How to use this forum" post for more information.

Maybe just start with adding a copy of your isrO in setup.

Add to void(setup)
TurnDetected = true;
up = (digitalRead(clk) == digitalRead(dt));

So you get the equilvant of turning the dial without actually having to turn it.

Whyall the delay()s? In the sketch I made that used rotary encoders and buttons I did not find that necessary, and feel like it would make it less responsive.

(here's the sketch, btw - LEDCTRLA/DriftAnimatePlus.ino at master · SpenceKonde/LEDCTRLA · GitHub - obviously it's got a lot of other crap in it that you're not interested in, but might be useful reference. Note that I do the rotary encoders "by hand" rather than using attachInterrupt() - IMO that is an abomination - and use PCINT's - which are really good for handling multiple rotary encoders)