C-4: Conditional Statement in Arduino Programming | Simulation | Arduino Programming Course by CS
1st Class: • C-1: Basic Concept of Arduino Programming ...
2nd Class: • C-2: Arduino LED Blink (use single & multi...
3rd Class: • C-3: Digital & Analog Signal Input | Ardui...
You'll use if statements all the time. The example below turns on an LED on pin 13 (the built-in LED on many Arduino boards) if the value read on an analog input goes above a certain threshold.
An else clause (if at all exists) will be executed if the condition in the if statement results in false . The else can proceed another if test, so that multiple, mutually exclusive tests can be run at the same time. Each test will proceed to the next one until a true test is encountered.
Conditional statements are a vital part in any programming language, because a conditional statement enables a computer or robot to perform different actions based on different sets of conditions. In the above pseudocode, Action I is taken if condition B is true and Action II is taken if condition B is false.
Can I program the Arduino board in C? In fact, you already are; the Arduino language is merely a set of C/C++ functions that can be called from your code. Your sketch undergoes minor changes (e.g. automatic generation of function prototypes) and then is passed directly to a C/C++ compiler (avr-g++).
A timer or to be more precise a timer / counter is a piece of hardware builtin the Arduino controller (other controllers have timer hardware, too). It is like a clock, and can be used to measure time events. The timer can be programmed by some special registers.
A boolean holds one of two values, true or false. (Each boolean variable occupies one byte of memory.)
Thank you
Cyber School