User manual

26
First of all, sensor 1 will detect any presence of object. If there are object
detected, the microcontroller will proceed to detect sensor 2, and in 0.5 second range,
there are object detected, the counter will counting up and relay will turned on. This
counting is represent a visitor is entering the laboratory. Henceforth, it is similar for
visitor that leaving the room. If sensor 2 detect the object first and a sensor 1 trace
0.5 second after sensor 1, the counter will counting down indicates a visitor is
leaving the laboratory. As there are nobody left inside the room, which counter will
hit zero, microcontroller will send data to control relay and turn off the lighting in the
room.
There also an additional function inside microcontroller to calculate the
height of the visitor that is entering and leaving the laboratory. It involve sensor 3 at
the top of the door to calculate the difference between the door and the detected
object that will equal to the height of the person.
3.2.3 Writing the control program
A programming language will be use depends on things such as desired
execution speed, program length and convenience. For this project, the most suitable
language is C++ language. The main advantages of C++ language are that there is
not much vocabulary to learn, and that the programmer can arrange the program very
fast. The high language C++ is very easy to learn and still a practical compact
language. It comprises a good semantic. The syntax of C is also clear [27]. This
language is a systems language suitable for low-level programming especially for
student. Finally, C language is easy to understand, has facilities for structured
programming and allows lexical variable scope and recursion, while a static type
system prevents many unintended operations [7].