Energia

## boolean

A boolean holds one of two values, true or false. (Each boolean variable occupies one byte of memory.)

#### Example

    int LEDpin = GREEN_LED;       // LED on pin 14
    int switchPin = PUSH2;   // pin 5

    boolean running = false;

    void setup()
    {
      pinMode(LEDpin, OUTPUT);
      pinMode(switchPin, INPUT_PULLUP);   // turn on internal pullup resistor
    }

    void loop()
    {
      if (digitalRead(switchPin) == LOW)
      {  // switch is pressed - pullup keeps pin high normally
        delay(200);                        // delay to debounce switch
        running = !running;                // toggle running variable
        digitalWrite(LEDpin, running)      // indicate via LED
      }
    }

#### See also

- constants
- boolean operators
- Variable Declaration

Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.

The text of the Energia reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Energia reference is based on Arduino reference. Code samples in the reference are released into the public domain.

©Energia | Edit Page | Page History | Printable View | All Recent Site Changes