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

Preface

Have you ever thought about making a robot? Or an electronic device that can be programmed for serving mechanical or logical purposes? If yes, then this book is the perfect guide for you. Throughout this book, you will be guided to learn C programming, which is required to program the microcontroller used in a logical device. You will also learn how you can develop your ideas about making an intelligent device. You will be able to program Arduino for your projects or play with Arduino for fun.

What this book covers

Chapter 1, Getting Started, in this chapter, you will learn about Arduino, types of Arduino, Install the Arduino IDE and know the Arduino IDE. This chapter will also have details about the functions of the Arduino IDE software.

Chapter 2, Our First Program! in this chapter, you will learn how you can connect your Arduino to the computer and write the first program for the Arduino. You will also learn how you can format your code. A simple Arduino project will also be discussed in this chapter.

Chapter 3, Exploring C with Arduino IDE, in this chapter, you will learn about C programming for Arduino. You will learn how you can declare variables, take inputs from the Serial Monitor, few mathematical operations, String, Arrays and many other things related to C programming.

Chapter 4, Blinking with Operations and Loops, in this chapter, you will learn logical operations and loops. You will also learn where you can use these techniques in your programs.

Chapter 5, Functions and Files with Arduino, in this chapter, you will learn about functions, functions types, and file handlings. You will also learn how you can connect an SD card to your Arduino and program for it to read and write.

Chapter 6, Arduino and C++, in this chapter you will learn basic things about object oriented programming, the benefits of OOP, and how you can use OOP in Arduino programming. At the end of this chapter you will be able to connect GSM module to your Arduino and make call or send and receive SMS with the module.

Chapter 7, Using Pointers and Structure, in this chapter you will go deeper into the C programming. You will learn the usages of pointer and structure. You will also learn how you can use them in your code.

Chapter 8, Working with Arduino Libraries, in this chapter, you will learn about Arduino libraries. You will learn how you can install a library and use it in your code. You will learn about few famous Arduino libraries.

Chapter 9, Let’s Build Something Awesome, in this chapter, you will build a number of projects including LED cube, a smart weather system, and a home security system. You will also learn how you can make your own projects.

Chapter 10, Few Error Handlings, in this chapter, you will learn how you can solve few common Arduino errors. You will also learn techniques for fixing errors that can occur in building any project or code.

What you need for this book

Software: Arduino IDE and Fritzing.

Who this book is for

This book is for hobbyists who have no knowledge about programming and microcontrollers, but are keen to learn C programming using a very affordable hardware device.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, path names, dummy URLs, user input, and Twitter handles are shown as follows: "On the last code we have written Serial.print("Hello Arduino!\n")."

A block of code is set as follows:

void setup() {
  Serial.begin(9600);
}
void loop() {
  Serial.print("Hello Arduino!\n");
}

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "If you go to Tools | Port you will see a bunch of port list."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.