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

Exercises


  • Write a program to check if a number is odd or even (hint: find the modulus of the number by 2, and if the modulus is equal to 1, then the number is even; else the number is odd).

  • Take inputs of three variables (Name, Age, and Email) from a user. If the age is greater than 20, print all the variables. If the age is equal to or less than 20, print "Sorry! You are not allowed!".

  • Take an input of three integers and print the largest integer (hint: follow the previous example)

  • Take the input of the marks of a student (four subjects) and find his GPA (hint: take variables as float; use if conditions to find the GPA of a subject; then add all the GPAs, divide the total with the total number of subjects, and print the value).

  • Define the days of a week from 1 to 7. Take an input of the day number, and if the day number is odd, print "Have a lovely day;" if the day number is even, print "It is a lovely day!"