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

Chapter 1. Getting Started

Since you have picked this book, this means you want to learn both about programming and electronics, especially microcontrollers. The book is designed to enable you to learn C programming easily and implement the language with an Arduino. I would suggest you do every code of the book by yourself and run them on the Arduino IDE. Microcontroller programming was hard before, but since the innovation of Arduino and the use of C programming on the Arduino board, microcontroller programming has become easy and fun.

Before going any further, let's understand the programming language C better. You may wonder why C programming is called C.

Well, before the creation of C, there was its predecessor programming language, called B. So, you should be able to guess from this where the name came from. The B language was developed by Ken Thompson at Bell Labs. At the same lab, the C language was developed in 1972 by Dennis Ritchie. The main purpose of creating this language was to design a UNIX operating system. Ken Thomson and Dennis Ritchie were the main developers of the UNIX operating system, so Dennis developed C to design UNIX.

C is not just a powerful language but a flexible one too. It is a portable language, because we can write a C program on one computer and compile to another with almost no modification.

To compile the source code of C, we need to have an IDE installed to our computers. Throughout this book we will learn C programming using the Arduino IDE. We will also be introduced to the Arduino IDE, its installation process, and how we can run our very first C program using an Arduino and the Arduino IDE.

Note

IDE stands for Integrated Development Environment. IDEs are used for software development. An IDE usually consists of an editor (where we can type code and comments), and a few tools along with a debugger (which is used to test the code to see if it has any errors). Most IDEs have a built in compiler (which converts source code/programming language into machine language).

Let's get introduced to an Arduino now.