Correct way of "NOT" in Arduino/C

(I'm typing it out right here, so this is not about errors, more the "correct way")

for example.

boolean SomeCondition = false;

...

...

{
   //Let's toggle SomeCondition.

  SomeCondition = !SomeCondition;
 or is it
  SomeCondition = NOT SomeCondition;
 
}

Which is the correct way to flip the state? - i'm not even sure NOT compiles... I just remember having
issues trying to invert the value and ended up using if (SomeCondition==true) .... SomeCondition=false else .... SomeCondition=true;

I'm in the middle of waiting for an 800 galaxy 2 image to download, so i'm taking a quick break while it finishes.

Bang. NOT is for Pascal (and other verbose languages).

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
boolean LEDState = false;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
}

// the loop routine runs over and over again forever:
void loop() {
  LEDState = !LEDState;
  digitalWrite(led, LEDState);   // turn the LED on (HIGH is the voltage level)
  delay(1000);         
  LEDState = !LEDState;
  // wait for a second
  digitalWrite(led, LEDState);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

This be the way then.... I think the first time i Tried it (never tried a not since because it never worked, so i used logical if conditions....) well, I think I must have missed out a 2nd delay to see the inverted signal and because of the no delay, it went back to a high state....

This was several months back, good to see it work! :slight_smile:

yeah yeah

void loop() {
  LEDState = !LEDState;
  digitalWrite(led, LEDState);   // turn the LED on (HIGH is the voltage level)
  delay(1000);         
}

I know....