And here we are. So at the top you could see that there is a comment that's a,
that doesn't quite have our name on it.
This is because this is not our code,
we're not the authors of this code, so,
we want to stress that we're using someone else's code
and they have all the rights to the code.
So you can find all of this on the Linaro GitHub,
and let's get started.
Yeah, so the first part though we want to get through is, as you can see,
it's a little bit scrolled down but you can see
all the definitions for whether it's connected.
The D6 just a reiteration of how the connections are.
Yeah, if you scroll up a little bit,
we can see just a reiteration we've,
we never had it connected before,
it's just good reference and good code commenting right there.
And the next part is just setting up the definitions for each pin,
meaning what pin value it is,
so that it's helpful later on to use.
And then finally, we have setting up all the pins and even serial communication.
All of them are set to input because we're just taking in
sensor data and serial begins just 9600.
You don't have to do that, but that's just a communication rate we are going to use.
So next we have to meet,
the meet up of the code itself.
So the first six lines of this function
would take the data from the sensor and put it in an end value.
And then after that,
it will print out the value and then with the label that corresponds to that value.
So, initially it will say, sensor,
and then the bar,
and then the value,
to tell you guys that this is how your output is going to look, and after that,
it has the light and followed by the light sensor data and then so forth,
for all six of your sensors.
After that, it will have a 400 millisecond delay.
This is for the mezzanine need to process all the information,
give it time a little bit.
And then, it will take in your next set of data,
and then it will have serial.print line and this is just to make everything neat.
Put a space after every single lane.
So let's now go into the python code to see what that was,
and then we can just do vim readserial.py.
Yeah, so the first,
this is very simple code.
So the first part is just using the Python Serial Library,
and the next three parts is just setting up the port that
we're going to use, the Baud rate,
which is the communications speed,
and the full device path of the serial port,
or the arduino serial port.
And the next part is just like a main function that we're going to use.
It's going to just give you a quick header and as you can see in the while loop,
you can see that it reads from arduino using a read line,
and then just prints whatever the heck it just right there.
And it's just got to try and accept this for accepting
or handling the key interrupts like when you
press control C. So this pretty much all the code.
This wasn't our main focus of this video or this project
as we just wanted to show you guys how a sensor data could be read easily using arduino.
So, feel free to use this,
take parts of it put in your own projects and we'll see you guys next time.