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

Collecting and showing data through serial port


Before going any further, let's discuss how we can print something using Arduino IDE. We already printed Hello Arduino in the previous chapter. If you don't know how to print something using serial monitor, please go to the previous chapter and then come back here.

Let's recap the print program we used.

We took two functions, setup() and loop(). Inside the setup function, we declared our baud rate as follows:

Serial.begin(9600); //default baud for serial communication 

Right after the baud was defined, we added a special function to print our text on the serial monitor. The function was Serial.print(). Inside the print()function, we wrote (in C we call it passed ) what we wanted to be seen on the serial monitor.

So, the full code for printing Hello Arduino is as follows:

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

You may know the difference between...