SunFounder 3in1 Kit
(continued from previous page)
#define NOTE_GS6 1661
#define NOTE_A6 1760
#define NOTE_AS6 1865
#define NOTE_B6 1976
#define NOTE_C7 2093
#define NOTE_CS7 2217
#define NOTE_D7 2349
#define NOTE_DS7 2489
#define NOTE_E7 2637
#define NOTE_F7 2794
#define NOTE_FS7 2960
#define NOTE_G7 3136
#define NOTE_GS7 3322
#define NOTE_A7 3520
#define NOTE_AS7 3729
#define NOTE_B7 3951
#define NOTE_C8 4186
#define NOTE_CS8 4435
#define NOTE_D8 4699
#define NOTE_DS8 49
4.5.8 5.8 User-defined Function
In c, we can divide a large program into the basic building blocks known as function. The function contains the set of
programming statements enclosed by {}. A function can be called multiple times to provide reusability and modularity
to the C program. In other words, we can say that the collection of functions creates a program. The function is also
known as procedureor subroutinein other programming languages.
There are the following advantages of functions.
• By using functions, we can avoid rewriting same logic/code again and again in a program.
• We can call C functions any number of times in a program and from any place in a program.
• We can track a large C program easily when it is divided into multiple functions.
• Reusability is the main achievement of C functions.
• However, Function calling is always a overhead in a C program.
There are two types of functions in C programming:
• Library Functions: the functions which are declared in the C header files.
• User-defined functions: the functions which are created by the C programmer, so that he/she can use it many
times. It reduces the complexity of a big program and optimizes the code.
In this project, define a function to read the value of the ultrasonic module.
Required Components
In this project, we need the following components.
It’s definitely convenient to buy a whole kit, here’s the link:
Name ITEMS IN THIS KIT LINK
3 in 1 Starter Kit 380+
156 Chapter 4. Basic Projects