Arduino - If Statement - Tutorialspoint

Home Whiteboard Graphing Calculator Online Compilers Practice Articles Tools Chapters Categories Library Courses Certifications Login Arduino Tutorial
  • Arduino - Home
  • Arduino - Overview
  • Arduino - Board Description
  • Arduino - Installation
  • Arduino - Program Structure
  • Arduino - Data Types
  • Arduino - Variables & Constants
  • Arduino - Operators
  • Arduino - Control Statements
  • Arduino - Loops
  • Arduino - Functions
  • Arduino - Strings
  • Arduino - String Object
  • Arduino - Time
  • Arduino - Arrays
  • Arduino Function Libraries
  • Arduino - I/O Functions
  • Arduino - Advanced I/O Function
  • Arduino - Character Functions
  • Arduino - Math Library
  • Arduino - Trigonometric Functions
  • Arduino Advanced
  • Arduino - Due & Zero
  • Arduino - Pulse Width Modulation
  • Arduino - Random Numbers
  • Arduino - Interrupts
  • Arduino - Communication
  • Arduino - Inter Integrated Circuit
  • Arduino - Serial Peripheral Interface
  • Arduino Projects
  • Arduino - Blinking LED
  • Arduino - Fading LED
  • Arduino - Reading Analog Voltage
  • Arduino - LED Bar Graph
  • Arduino - Keyboard Logout
  • Arduino - Keyboard Message
  • Arduino - Mouse Button Control
  • Arduino - Keyboard Serial
  • Arduino Sensors
  • Arduino - Humidity Sensor
  • Arduino - Temperature Sensor
  • Arduino - Water Detector / Sensor
  • Arduino - PIR Sensor
  • Arduino - Ultrasonic Sensor
  • Arduino - Connecting Switch
  • Motor Control
  • Arduino - DC Motor
  • Arduino - Servo Motor
  • Arduino - Stepper Motor
  • Arduino And Sound
  • Arduino - Tone Library
  • Arduino - Wireless Communication
  • Arduino - Network Communication
  • Arduino - Quick Guide
  • Arduino - Useful Resources
  • Arduino - Discussion
  • Selected Reading
  • UPSC IAS Exams Notes
  • Developer's Best Practices
  • Questions and Answers
  • Effective Resume Writing
  • AI Based Resume Builder
  • Personal AI Study Assistant
  • Generate Coding Logic
  • HR Interview Questions
  • Computer Glossary
  • Who is Who
Arduino - If statement Previous Quiz Next

It takes an expression in parenthesis and a statement or block of statements. If the expression is true then the statement or block of statements gets executed otherwise these statements are skipped.

Different forms of if statement

Form 1

if (expression) statement;

You can use the if statement without braces { } if you have one statement.

Form 2

if (expression) { Block of statements; }

if Statement Execution Sequence

IF Statement

Example

/* Global variable definition */ int A = 5 ; int B = 9 ; Void setup () { } Void loop () { /* check the boolean condition */ if (A > B) /* if condition is true then execute the following statement*/ A++; /* check the boolean condition */ If ( ( A < B ) && ( B != 0 )) /* if condition is true then execute the following statement*/ { A += B; B--; } } arduino_control_statements.htm Print Page Previous Next Advertisements

Tag » Arduino If Statement