Hi!
In this video we're gonna use Multi-File-Sketch-Technique
in Arduino.
We're gonna use:
HC SR04 Ultrasound Sensor Distance and
Mini Infrared PIR Motion Sensor Detector
LED
The arduino LCD Keypad shield
and Temperature Sensor - TMP36
Please visit my github, J3, @giljr, Ardu_Serie
repository, and look for 45 prefix, which
means Ardu_Serie number 45.
We have published 6 codes for this lab.
Good!
Let's review where we start off ... We just
read on lcd what button we just pressed.
we define variables used by the panel and
buttons.
And depending on which buttons was pushed,
we perform an action.
Right; Left; UP; Down; Select or none of the
buttons.
Here is the connections:
For HC TRIG goes on 11 ECHO goes on 12
For LCD Data bus on D4 througth D7 ;
For PIR goes on the pin 2;
For TMP36 goes on pin Analog 1;
For LED goes on pin 13;
In order to facilitate the connections before
putting the shield distribute the pins of
the PIR and TPM36 on the power bus and connect
the signals D2 and A1.
We will connect the trigger of the ultrasound
on the pin 11 and the echo on the pin 12;
see the schema of the LCD Keypad shield,
as well as the power bus on these pins.
LED goes on pin 13.
Good!
We're ready! now we go to the codes.
The idea is for each implementation to simplify
the code using multi file sketch.
Come with us!
The first code working with multi file 01
All the connection are presented in the comments,
see in my github all the comments so that
you can understand the code
and we will run this code and see what results.
When we push the buttons on the right side
we have the distance measured by the ultrasound...
let me improve my hand position ...
Ok the measurements are being sent to the
LCD. great for now!
As for the PIR, if someone passes in the front
of the sensor, we have the LED on and the
LCD display indicating that movement has been
detected!
Let's wait for the sensor to discharge, releasing
the LED.
Good!
Motion Ended!
Now let's check the temperature sent by the
TMP36.
Ups! wrong connection...sorry.
minus 40 degrees!
Wow, it's cold over here, huh?
Now let's go to the second code.
All the same.
The difference:
Let's create a new HC SR04 class.
Declare variables, private and public methods,
and
a pointing object for the class.
We call it HC. exactly here that we trigger
our object.
See?
Let's run the code and see if everything still
works like
the previous code...
Let's manipulate the buttons.
OK...
Everything...
looks fine...
Yeah!
Now the third code.
Now there are two classes: HC and PIR point
h.
Do not forget to save the classes with the
extension point h.
See the positions that we have been inserted
the calls to the HC and PIR classes...
Let's run this code!
And see...
...if everything looks...
Yeah!
Alright!
The 
last code.
the three HC , PIR and TMP36 classes.
See the inclusions.
See how clean the main code is NOW!
when I press the select key, I send this bye
message.
Good!
Let's run this code!
I hope you now know how to improve your
coding technique in Arduino.
If you enjoyed this video please let me know.
I would also appreciate your feedback on the
content
and suggestions for improvement.
This is your host,
J3!
Thank you for now!
