
Learning C for Arduino
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
- 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
Book DescriptionThis 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
Who this book is forThis 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.
All prices
More details
Person
Syed Omar Faruk Towaha is a data scientist, and currently working at Meta. He has two bachelor's degrees, one in Physics, another in Computer Science and a Master's in Data Science. He is based in London, England, and has interests in data science and IoTs. While Syed is not busy with his jobs, he uses his time to write something about new technologies. His recent publications include Building Smart Drones With ESP8266 and Arduino, Introduction to Rust Programming, Learning C for Arduino, and JavaScript Projects for Kids.
Content
- Cover
- Copyright
- Credits
- About the Author
- About the Reviewer
- www.PacktPub.com
- Customer Feedback
- Table of Contents
- Preface
- Chapter 1: Getting Started
- Arduino
- Types of Arduino
- Arduino Uno
- Arduino Mega
- Arduino Nano
- Arduino Leonardo
- Arduino Mini
- Arduino Micro
- Exploring Arduino Uno
- USB port
- External power jack
- Analog pins
- Digital pins
- ICSP
- Microcontroller
- Reset button
- Connecting Arduino to PC
- Downloading and installing Arduino IDE
- Downloading Arduino IDE
- Installing Arduino IDE
- Installing Arduino IDE on Windows
- Installing Arduino IDE on Ubuntu/Linux
- Installing Arduino IDE on Mac
- Explore Arduino IDE
- Summary
- Chapter 2: Our First Program!
- Connecting your Arduino
- Hello Arduino!
- Dissecting our first code
- setup() function
- loop() function
- Things to remember
- Watch your case
- Don't forget your semicolon!
- Adding both Setup() and Loop() functions
- Minding the baud rate
- Formatting your code
- Turning the LED On
- Blink a LED
- Commenting
- Try at home
- Keyboard shortcuts
- Summary
- Chapter 3: Exploring C with Arduino IDE
- Variables
- Exercise
- Data types
- Integers
- Rational numbers or fractions
- Characters and strings
- Booleans
- Collecting and showing data through serial port
- Mathematical operations
- Addition
- Subtraction
- Exercise
- Multiplication
- Division
- Modulus
- Arrays
- Exercise
- Strings and operations with strings
- Conversion of strings
- Exercise
- Summary
- Chapter 4: Blinking with Operations and Loops
- Expression in C
- Logical operations in C
- If-statement
- Nested if
- Logical operators
- AND operator
- OR operator
- NOT operator
- If-else
- Switch-case
- Exercises
- Loops
- for loop
- Nested for loop
- While loop
- do-while loop
- Exercise
- Summary
- Chapter 5: Functions and Files with Arduino
- Functions
- Types of functions
- Functions with no arguments and a return value
- Function with arguments and no return value
- Functions with arguments and a return value
- Usages of functions
- Exercise
- Data logging
- File handling
- Connecting an SD card to your Arduino
- Formatting the SD/Micro SD card
- Connecting the module to the Arduino
- Naming your data file
- Reading a file
- Importing a library
- Setting CS/SS pin number
- Writing on a file
- Exercise
- Summary
- Chapter 6: Arduino and C++
- Object Oriented Programming
- Objects
- Class
- Going deeper into class
- Understanding OOP better
- Fundamentals of OOP
- Encapsulation
- Data Abstraction
- Constructor
- Virtual function
- Polymorphism
- Pointer and reference in polymorphism
- Method overload
- Method overriding
- Inheritance
- Exercises
- Benefits of OOP
- Using OOP with Arduino
- GSM modules
- Types of GSM module
- Getting to know SIM900A mini better
- Connecting the GSM Shield to the Arduino
- Arduino library
- Making a call using GSM module
- AT commands
- Usages and rules of AT Commands
- Sending an SMS
- Receiving an SMS
- Summary
- Chapter 7: Using Pointers and Structure
- Pointers
- Declaring a pointer
- Reference point
- Types of pointers
- Pointers and arrays
- Usages of pointers
- Learning about structure
- Structure and function
- Pass by value
- Pass by reference
- Nested structure
- Exercise
- Summary
- Chapter 8: Working with Arduino Libraries
- Arduino library
- In Windows
- In OSX
- Linux OS
- Types of libraries
- The Servo library
- Exploring Servo.h library
- Knob the Servo
- Sweep with Servo
- The Firmata library
- The SoftwareSerial library
- [The LiquidCrystal library]
- The LiquidCrystal library
- Uses of LiquidCrystal Library
- The Stepper library
- Installing a library
- Removing a library
- Creating our own library
- Summary
- Chapter 9: Lets Build Something Awesome
- LED cube
- Smart weather system
- Home security
- Summary
- Chapter 10: Few Error Handlings
- Few common errors
- Arduino is connected but cannot be found by the computer
- Cannot upload programs to the Arduino board
- Arduino software
- Update the drivers
- Access to the serial port
- Physical connection
- Auto-reset
- Bootloader
- java.lang.StackOverflowError
- Arduino software freeze when I try to upload a program
- Board doesn't turn on (the green power LED doesn't light up)
- Get an error when launching arduino.exe on Windows
- Could not find the main class
- Cygwin conflicts on Windows
- Tools | Serial Port menu is not visible
- gnu.io.PortInUseException on Mac
- Sketch appear to upload successfully but not do anything
- Undeclared functions or undeclared types error
- Invalid device signature when trying to upload a sketch
- 'xxx' does not name a type error
- Library is not Installed properly
- Wrong folder location
- Library dependencies
- Wrong library name
- Wrong folder name
- Forgot to close the Arduino IDE
- Check your hardware connections
- Check the coding syntax error
- Use serial monitor
- Stay connected with the Arduino forum
- Summary
- Index
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.
File format: PDF
Copy-Protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (only limited: Kindle).
The file format PDF always displays a book page identically on any hardware. This makes PDF suitable for complex layouts such as those used in textbooks and reference books (images, tables, columns, footnotes). Unfortunately, on the small screens of e-readers or smartphones, PDFs are rather annoying, requiring too much scrolling.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our eBook Help page.