Troube with if logic, triggeres at start of cycle when it shouldn't

Edit: I've decided there are other forums to participate in.

I can't figure out why...

I did. It's right there after the

void httpRequest(int pin, int value) {

line...

... is not really in there - there is more code after that which is un-interesting/unrelated to the problem

technicalguy:
… is not really in there - there is more code after that which is un-interesting/unrelated to the problem

It’s funny, but bugs have a way of hiding where you don’t expect to find them. Indeed, bugs are always in the last place you look.

Also, it would help us to read your code if, while the cursor is in the source code window in the IDE, you’d use Ctrl-T to reformat your code to make it easier for us to read.

…except when I tried to post the whole thing I get “message length exceeds 9000 characters”
…and then when I try to fix it I get the “exceeded the number of posts you can make in a 5 minutes period” nonsense.

This forum is really, truely, frustrating.

I feel like nobody has even read my if/else loop which is where I believe the problem actually is, but everyone is quick to provide feedback on the formatting of my post :frowning:

…anyway, I’ve updated the original code block to be more complete.

First, meaningful names are important. sensor1st is not a meaningful name. If it was, you wouldn’t need comments (useless as they are) to describe the variables.

Second, using an int to store 0 or 1 is wasteful. Use a byte. Better yet, use a boolean, and store true or false.

Third, using some arrays would allow you to get rid of a lot of repetitive code.

Fourth, literals are interpreted as ints unless the context says otherwise. 300000 isn’t an int. 300000UL makes it clear that the literal is to be interpreted as an unsigned long.

Fifth, it’s ONE statement per line, not stuff (and I’m being charitable) like this:

    client.print("GET /state.xml?arduino2p"); client.print(pin); client.print("v"); client.print(value); client.println(" HTTP/1.1");

Sixth, what do your serial print statements tell you id happening?

And, finally, your diatribe about this forum is unwarranted. There are sticky threads at the top of the forum, that you were supposed to read BEFORE posting here. They do NOT say that it is OK to post a snippet of code.

And, not to be forgotten - DO NOT EVER REPLACE CONTENT OF A THREAD AGAIN. Post a reply containing the complete code, answers to questions, etc.

technicalguy:
Edit: I’ve decided there are other forums to participate in.

Goodbye. User banned for removing his thread. Very bad manners.

PaulS is right. Replacing your original thread with different code makes any replies look stupid. Post a new reply with your updated code.

technicalguy:
…except when I tried to post the whole thing I get “message length exceeds 9000 characters”
…and then when I try to fix it I get the “exceeded the number of posts you can make in a 5 minutes period” nonsense.

This forum is really, truely, frustrating.

I feel like nobody has even read my if/else loop which is where I believe the problem actually is, but everyone is quick to provide feedback on the formatting of my post :frowning:

You can attach your code to a forum post. That gets around the posting limit.

How to use this forum

Properly formatted code makes bug finding much easier.

We are trying to help you, but you don’t want to be helped, right?