Book Image

Learning C for Arduino

By : Syed Omar Faruk Towaha
Book Image

Learning C for Arduino

By: Syed Omar Faruk Towaha

Overview of this book

This book will start with the fundamentals of C programming and programming topics, such data types, functions, decision making, program loops, pointers, and structures, with the help of an Arduino board. Then you will get acquainted with Arduino interactions with sensors, LEDs, and autonomous systems and setting up the Arduino environment. Moving on you will also learn how to work on the digital and analog I/O, establish serial communications with autonomous systems, and integrate with electronic devices. By the end of the book, you will be able to make basic projects such as LED cube and smart weather system that leverages C.
Table of Contents (17 chapters)
Learning C for Arduino
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Logical operators


Before going any further, let's learn about a few logical operators. There are only three types of logical operators in C. They are, AND, OR, and NOT. All three operators cover any logical operation. These operators help to remove complexities and shorten the code. Let's learn their symbols first:

Name

Symbol

Meaning

AND

&&

This means, if all the conditions are true, then the condition is true.

OR

||

This means, if any of the conditions are true, then the condition is true.

NOT

!

This operator reverses the condition.

Now we will learn about the operators in detail.

AND operator

The AND operator means if all the conditions fulfill the condition, the condition is true.

Let's look at an example.

Suppose, if today is Monday and the weather is good, I will go to school. See, if both conditions is true, I will do something. But if any of the conditions are false, I won't go to school. In this case, we can either use a nested if or a logical operator...