bool
יכול להכיל רק שני מצבים: true או false. כל משתנה מסוג bool
תופס בית (byte) אחד בזכרון.דוגמה
- קוד: בחר הכל
int LEDpin = 5; // LED on pin 5
int switchPin = 13; // momentary switch on 13, other side connected to ground
bool running = false;
void setup()
{
pinMode(LEDpin, OUTPUT);
pinMode(switchPin, INPUT);
digitalWrite(switchPin, HIGH); // turn on pullup resistor
}
void loop()
{
if (digitalRead(switchPin) == LOW)
{ // switch is pressed - pullup keeps pin high normally
delay(100); // delay to debounce switch
running = !running; // toggle running variable
digitalWrite(LEDpin, running) // indicate via LED
}
}
ראו גם:
קבועיםפעולות בוליאניות (boolean operators)
הגדרת משתנים
פירוט שפת תכנות לסביבת Arduino
עמוד זה הוא תרגום של boolean לפי רישיון Creative Commons Attribution-ShareAlike 3.0.