Posts

Showing posts from July, 2017

Arduino - Strings

Image
Strings are used to store text. They can be used to display text on an LCD or in the Arduino IDE Serial Monitor window. Strings are also useful for storing the user input. For example, the characters that a user types on a keypad connected to the Arduino.  Read More:  Arduino Info Strings There are two types of strings in Arduino programming − Arrays of characters, which are the same as the strings used in C programming. The Arduino String, which lets us use a string object in a sketch. In this chapter, we will learn Strings, objects and the use of strings in Arduino sketches. By the end of the chapter, you will learn which type of string to use in a sketch. You should also have a look at this list of Arduino Projects . String Character Arrays The first type of string that we will learn is the string that is a series of characters of the type  char . In the previous chapter, we learned what an array is; a consecutive series of the same type of variab...

Arduino - Functions

Image
Functions allow structuring the programs in segments of code to perform individual tasks. The typical case for creating a function is when one needs to perform the same action multiple times in a program.  Read More:  Arduino Info Standardizing code fragments into functions has several advantages − Functions help the programmer stay organized. Often this helps to conceptualize the program. Functions codify one action in one place so that the function only has to be thought about and debugged once. This also reduces chances for errors in modification, if the code needs to be changed. Functions make the whole sketch smaller and more compact because sections of code are reused many times. They make it easier to reuse code in other programs by making it modular, and using functions often makes the code more readable. There are two required functions in an Arduino sketch or a program i.e. setup () and loop(). Other functions must be created outside the bracket...

Arduino - Loops

Image
Programming languages provide various control structures that allow for more complicated execution paths.  Read More:  Arduino Info A loop statement allows us to execute a statement or group of statements multiple times and following is the general form of a loop statement in most of the programming languages − C programming language provides the following types of loops to handle looping requirements. S.NO. Loop & Description 1 while loop while loops will loop continuously, and infinitely, until the expression inside the parenthesis, () becomes false. Something must change the tested variable, or the while loop will never exit. 2 do…while loop The  do…while  loop is similar to the while loop. In the while loop, the loop-continuation condition is tested at the beginning of the loop before performed the body of the loop. 3 for loop A  for loop  executes statements a predetermined number of times. The control expression for the lo...