Arduino first timer!! Why don`t this program work

String Innkommende;
int Skallsikring1 = 1;
int Skallsikring2 = 2;
int Skallsikring3 = 3;
int UtgangAlarm = 13;
void setup() {
Serial.begin(9600);
pinMode(Skallsikring1, INPUT);
pinMode(Skallsikring2, INPUT);
pinMode(Skallsikring3, INPUT);
pinMode(UtgangAlarm, OUTPUT);
}

void loop() {
if (Serial.available()) {
if ((Skallsikring1 != LOW) || (Skallsikring2 != LOW)|| (Skallsikring3 != LOW) == HIGH){
digitalWrite(UtgangAlarm, HIGH);
Serial.print("Situasjon:");
Serial.println(7); //Whatever input status - program will always go this way???

} else {
digitalWrite(UtgangAlarm, LOW);
Serial.print("Situasjon:");
Serial.println(6);
}

delay(1000);
}

}

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. If your browser doesn't show the posting toolbar then you can just manually add the code tags:
[code]``[color=blue]// your code is here[/color]``[/code]
Using code tags and other important information is explained in the How to use this forum post. Please read it.

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read. If you're using the Arduino Web Editor you will not have access to this useful tool but it's still unacceptable to post poorly formatted code. I recommend you to use the standard IDE instead.

Please remove unnecessary blank lines from your code before posting to the forum. One or two to separate code into logical sections is fine but large spaces for no reason or random blank lines just make for more scrolling when we're trying to read your code.

I'm guessing this is your problem:

(Skallsikring3 != LOW) == HIGH
(Skallsikring1 != LOW)

You've got Skallsikring defined in your code as 1 and you never change it. LOW is defined in the core as 0. 0 will never equal 1 no matter how many times you test it. So I don't see the point of this part. The same with the other three parts of that statement.

Aside from that, you really didn't say what the code was supposed to do. I will tell you now that the code absolutely does work. It does exactly as it is written to do. It's just that it isn't doing what you want it to do. If you want us to help you change that, then telling us what you want it to do seems like a pretty important detail. Don't you think?

Thank you for your help.

This is my first attempt at programming of Arduino. Also my first posting on this forum. Sorry for missing information in my frustrating question.

The software are ment to have three inputs and one output. If one of the inputs are active it shall activate the output.

When the output is HIGH then send a serial print
When the output is LOW then send a serial print

Have you had a look at any of the example codes that come with the IDE? Try some of the basics about how to read a pin. I think you'll see your error pretty quickly.

By the way, the Serial interface uses pins 0 and 1. You can't use those for your inputs if you want to use Serial.

Thanks.

You gave me progress with that by the way!. Now the output is not always HIGH any more, but not possible to get HIGH.

I have used many hours (do not dear to tell how many) trying to get a grip of this programming metod. This is totally new for me.

So you've changed the code. Now the new code does something different. Think for a minute, what might we need to see?

Please read the forum sticky "How to use this forum" before posting anymore. Please use code tag when posting code.

Hope that this are posted correctly?

I am very grateful for your help.

  String Innkommende;
  int Skallsikring1 = 2;
  int Skallsikring2 = 3;
  int Skallsikring3 = 4;
  int UtgangAlarm = 13;
  void setup() {
      Serial.begin(9600);
      pinMode(Skallsikring1, INPUT);
      pinMode(Skallsikring2, INPUT);
      pinMode(Skallsikring3, INPUT);
      pinMode(UtgangAlarm, OUTPUT);
  }

  void loop() {
      if (Serial.available()) {
            if ((Skallsikring1 == HIGH) || (Skallsikring2 == HIGH)|| (Skallsikring3 == HIGH) == HIGH){
              digitalWrite(UtgangAlarm, HIGH);
                Serial.print("Situasjon:");
                Serial.println(7); 
          } else {
              digitalWrite(UtgangAlarm, LOW);
                Serial.print("Situasjon:");
                Serial.println(6);
          }

          
           
          delay(1000);
      }


  }
(Skallsikring1 == HIGH)

OK, same problem. But HIGH is defined in the core as 1 and 1 does not ever equal 2 so this one is always false. The rest are always false as well. There's no need to test whether 1 equals 2.

if ((Skallsikring1 == HIGH) || (Skallsikring2 == HIGH)|| (Skallsikring3 == HIGH) == HIGH)

And what is that extra ==HIGH at the end?

Did you do like I said and look at any of the example codes about reading a pin? Even the button example would help.

Or try reading through the reference (under Learning at the top of this page).

  int Skallsikring1 = 2;
  
            if ((Skallsikring1 == HIGH)

If I tell you that HIGH has the value 1, how likely do you think it is that that "if" expression will ever be true?

I would like to see how it’s wired up and if your using something that requires a pull up or a pull down resistor.

You have inputs but they may not be wired correctly or you need to use input pull-up in addition to code corrections.

Also get rid of Serial available. What do you need it for?

The reason your having an issue is because you have to monitor the state change of your inputs.

You may keep your first set of ints as they were originally but you must use a state variable and tell that to be the read of your PIN number whether the pin is 1 or 2 or whatever.

Then when you write the of statement use the state variable as your high and low. NOT THE PIN INT.

  int Skallsikring1 = 2;
  int Skallsikring2 = 3;
  int Skallsikring3 = 4;
  int UtgangAlarm = 13;
  void setup() {
      Serial.begin(9600);
      pinMode(Skallsikring1, INPUT);
      pinMode(Skallsikring2, INPUT);

So SkallsikringX are Arduino pin numbers?

      if (Serial.available()) {
            if ((Skallsikring1 == HIGH) || (Skallsikring2 == HIGH)|| (Skallsikring3 == HIGH) == HIGH){
              digitalWrite(UtgangAlarm, HIGH);

[/code]

But here, you are accessing only the pin numbers; to test the values of the pins themselves, you need to access them via the digitalRead() function:

           if ((digitalRead(Skallsikring1) == HIGH) || (digitalRead(Skallsikring2) == HIGH) ...

Also, you check Serial.available(), but never actually read the data, so once you've sent data, Serial.available() will be true forever...

Thanks for all help.

Finally the program works as it should.