Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning C for Arduino
Learning C for Arduino

Learning C for Arduino: A comprehensive guide that will help you ace C's fundamentals using the powerful Arduino board

By Syed Omar Faruk Towaha
€28.99 €8.99
Book Mar 2017 378 pages 1st Edition
eBook
€28.99 €8.99
Print
€37.99
Subscription
€14.99 Monthly
eBook
€28.99 €8.99
Print
€37.99
Subscription
€14.99 Monthly

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Mar 24, 2017
Length 378 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781787120099
Category :
Languages :
Table of content icon View table of contents Preview book icon Preview Book

Learning C for Arduino

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.

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.

Left arrow icon Right arrow icon

Key benefits

  • Get hands-on experience with the Ardruino board and learn to control it with your programming skills
  • Learn the essential concepts of C such as variables, data structures, functions, loops, and pointers
  • Work with electronic devices such as LEDs, switches, and motors and connect them to Arduino using C

Description

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.

What you will learn

Play with mathematical operations using C Use logical operations and loops to play with LEDs and the Arduino board Create custom functions using C and connect an SD card to the Arduino Use Object-oriented Programming to connect a GSM module to the Arduino board Play with an LCD board and Servo using standard Arduino libraries Build projects using Arduino such as a LED cube, a smart weather system, and home security Identify and fix common errors on an Arduino board

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Mar 24, 2017
Length 378 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781787120099
Category :
Languages :

Table of Contents

17 Chapters
Learning C for Arduino Chevron down icon Chevron up icon
Credits Chevron down icon Chevron up icon
About the Author Chevron down icon Chevron up icon
About the Reviewer Chevron down icon Chevron up icon
www.PacktPub.com Chevron down icon Chevron up icon
Customer Feedback Chevron down icon Chevron up icon
Preface Chevron down icon Chevron up icon
1. Getting Started Chevron down icon Chevron up icon
2. Our First Program! Chevron down icon Chevron up icon
3. Exploring C with Arduino IDE Chevron down icon Chevron up icon
4. Blinking with Operations and Loops Chevron down icon Chevron up icon
5. Functions and Files with Arduino Chevron down icon Chevron up icon
6. Arduino and C++ Chevron down icon Chevron up icon
7. Using Pointers and Structure Chevron down icon Chevron up icon
8. Working with Arduino Libraries Chevron down icon Chevron up icon
9. Lets Build Something Awesome Chevron down icon Chevron up icon
10. Few Error Handlings Chevron down icon Chevron up icon

Customer reviews

Filter icon Filter
Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%

Filter reviews by


No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.