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

Arduino


Arduino is a microcontroller board. People also call it a prototype board. In a nutshell, an Arduino board is a small computer with a processor, RAM, ROM etc. Arduino is open source hardware - you might have heard of open source software. Open source software is computer software distributed with a license that gives the users the right to see its source code. A Free Open Source Software license provides the rights to study, change and distribute the software to anyone for any kind of purpose. Open source software is usually developed by a group of open source enthusiasts who develop and gradually fix bugs of the software.

Since Arduino is open source hardware, we can build our own Arduino and also develop it for the purpose of our goals. We can change it to whatever we want.

Types of Arduino

Since Arduino is open source hardware, people around the world modify the board according to their needs. There are a few companies that produce different versions and types of Arduino. Let's get introduced to a few famous types of Arduinos.

Arduino Uno

Arduino Uno is the most-used Arduino board. It is based on the ATmega328 microcontroller. It has 14 digital pins and six analog inputs. We will know more about analog and digital pins in the next chapters.

The ATmega328 has 32Kbytes flash memory, 32 pins, 20MHz maximum operating frequency and 8-bit AVR CPU. The following image is an Arduino Uno board and an ATmega328 microcontroller with its pin out:

Arduino Mega

Arduino Mega is a microcontroller board that is famous for providing more pins. It uses ATmega2560, and has 54 digital pins and 16 analog inputs.

The ATmega2560 has 256Kbytes of flash memory, 100 pins, 16MHz operating frequency and 8-bit AVR CPU. The following image is an Arduino Mega and an ATmega2560 microcontroller with its pin out:

Arduino Nano

Arduino Nano is usually chosen for prototypes with a small form factor. It is based on the ATmega328 microcontroller, which is same as the Arduino Uno. It has 14 digital pins and eight analog inputs. The following image is an Arduino Nano:

Arduino Leonardo

Arduino Leonardo is similar to Arduino Uno. The main difference is that it has a soldered microcontroller instead of a removable one, and the model of the microcontroller is ATmega32U4. It has 20 digital pins and 12 analog inputs. The following image is an Arduino Leonardo with the ATmega32U4 microcontroller's pin out:

Arduino Mini

Arduino Mini is a small prototyping device that is based on the ATmega168. It does not come with a USB port. Arduino Mini has 14 digital pins and eight analog inputs. The ATmega168 has 16Kbytes of flash memory, 20MHz maximum operating frequency and an 8-bit AVR CPU. The following image is an Arduino Mini and an ATmega168 microcontroller with its pin out. The following image is image of an Arduino menu with the ATmega168's pin out:

Arduino Micro

Arduino Micro is based on the ATmega32u4 microcontroller. It uses the same microcontroller as the Arduino Leonardo. There are fewer digital and analog pins than in the Arduino Leonardo - the Micro has 20 digital pins. It comes with a micro USB port and ICSP pins. The following image is an Arduino Micro:

Throughout this book, we will use the most famous board, Arduino Uno. Arduino Uno has a replaceable microcontroller, ATmega 328. Before connecting an Arduino to our PC, let's get to know our Arduino better.