The logical NOT operator

Im a noob so a complete explanation would be great.

In this code: What does serial.printIn mean? What does a! mean? What does return a mean?

int a = 0; void setup() { pinMode(7, INPUT_PULLUP);

} void loop (); int bb = digitalRead(7);

Serial.println(String (a)); if (a != 0 && bb == LOW) { tone(0, alarm); a = 0; return a; }

There is a page called the language reference. You could look there.

https://www.arduino.cc/reference/en/language/structure/control-structure/return/

https://www.arduino.cc/reference/en/language/functions/communication/serial/println/

a != 0

a not(!) equal(=) 0(zero) https://www.arduino.cc/reference/en/language/structure/boolean-operators/logicalnot/

https://www.arduino.cc/reference/en/language/structure/comparison-operators/notequalto/

groundFungus: There is a page called the language reference. You could look there.

https://www.arduino.cc/reference/en/language/structure/control-structure/return/

https://www.arduino.cc/reference/en/language/functions/communication/serial/println/

a != 0

a not(!) equal(=) 0(zero) https://www.arduino.cc/reference/en/language/structure/boolean-operators/logicalnot/

Yeah, I saw those pages but I don't understand those explanations, that's why I asked here.

They all mean nothing because the sketch won't compile.

You've got a ';' instead of a '{' after "loop()'.

The value 'alarm' is not declared.

You can't return the value 'a' from loop() because the 'void' in 'void loop()' means "This function does not return a value".

If those are fixed:

"What does serial.printIn mean?" It means send characters to the Serial Monitor (if it is open) to display '0' (the value of 'a') and go down to the beginning of the next line.

"What does a! mean?" It doesn't. 'a' is an identifier. '!=' is an operator meaning 'is not equal to'.

'What does return a mean?' If loop() was declared 'int loop()' instead of 'void loop()' it would mean that the value of 'a' would be returned as the value of the function.

Artpunk00: What does serial.printIn mean?

Note that it's print[b]l[/b]n, not print[b]I[/b]n. The two letters (capital i vs lower case l) look similar, especially in some fonts where they are identical but it's very important to get it right. The ln means that it starts a new line of text after that print, as opposed to Serial.print(), which doesn't.

Also, it's Serial, not serial. It's extremely important to be precise in computer programming. If you don't pay attention to small details like this you are going to have a really hard time.

Artpunk00: Yeah, I saw those pages but I don't understand those explanations, that's why I asked here.

When that happens you need to tell us the part that you did not understand. That way we can focus out explanation where it will be most useful.

Better still, post the code that you tried.

...R

PS... Please modify your Original Post and enter a proper title. It is very hard to click a link that just has a single character, especially a narrow character.

...R