One of the most important things that we can exchange between desks is actually structures.
Now, we've talked about structures before and we know that they can hold multiple types together in
one structure.
So let's see how we can send the whole the structure that contains multiple valuable all at once in
between desks.
Let's see how we can do this exchange.
We remember that in order to define a structure, we need to say type def.
And this structure is going to have a name.
Well, we're going to create a structure that contains all the information about a certain sensor.
OK, so let's say this is a sensor in it.
So let us see what kind of information a sensor can have.
Well, let us open the curly brackets first and let us think we have the name of the sensor.
So is it an ultrasonic sensor or is it a proximity sensor?
Is it a temperature humidity?
Is it a color sensor?
There is no doubt that we could use here.
So we're going to say, Char, we need a string here.
Senser name.
OK, this is the first data next, is it analog or digital?
So we could say also the type.
OK, so here also it's a string.
And we're going to say sensor type, is it analog is a digital what kind of sensor it is next?
What is the value of the sensor while we are reading right now?
So here we are going to say integer.
Sensor data.
This will give you a live reading from the census.
And next, we have the scale.
Remember every sensor you need to scale it in order to get the value in a standardized unit.
When you read the value directly from a sensor, you read it as a voltage over carbon.
However, when you scale it, you get it as a standardized unit.
So I'm going to say here a float and I'm going to say denser scale unit.
OK, so we have this for I want to transfer these in-between tasks.
Now I'm going to delete this line.
And I'm going to delete this for loop from the previous example.
OK, now we need to create an instance of sensor in it, but first we need a semicolon here.
Let's edit, OK, now we need an instance of that.
So I'm going to say then, sir.
In it and is it going to be called ultrasonic, so I'll have an ultrasonic sensor.
Now let us initialize it.
Remember, there is two ways to initialize it, as we have learned.
And I'm going to use the Longway here so that you can later link it to a real sensor right now, I'm
not going to be linking this to anything.
I'm going to be sending constant values, let's say, in the field of sensory data.
So I'm not going to link it to anything on my Adreno.
I'm going to be sending a constant value of, let's say, thirty two or fifty five or whatever.
We're going to say ultra sonic dot.
Now, this dot will let us access any of these types of assistance, her name.
And the censor name is Ultra.
Doneck.
Next.
We have also ultrasonic that what's the next information, what is the type?
Well, it is an analog great.
So this is thenceforth type.
Analog.
Next, data and scale, so we have data.
Or sensor data.
Let's say we are sending a constant value of 55.
And finally, we have the scale so ultra sonic sensor scale that say it's equal to four point two,
OK, it's a flood.
Next, we need to send this.
So all I need to do is just give a reference and send ultra.
Thurrock.
Now, I'm sending the ultrasonic value and the data says, well, we need to work on that, we have
multiple data being sent here.
First one is going to be.
Ultra Sonic, the.
That's her name.
I'm not going to.
It was L.N. during the sprint.
At the space here.
OK, so this is the first value I'm going to put all the values on one line, so I'm going to copy paste.
These so here we have a cancer type.
Here we have sensor data.
And finally, we have.
That's of scale back.
Now, there is one more thing that we need to modify, which is the queue here, what is the type of
the data that the CICU will have?
Well, we need the size of the structure, right?
So always the queue will have the size of the structure it's holding or is it an integer?
Is it a string or is it the whole structure like this?
It will automatically calculate what is the size of all of these?
OK, now let us upload to my connected UNO.
We forgot to add the eight here.
It has.
Then scale unit is what it's called, so here we have Sundsvall skilled unit and also we have unit.
Let us try again.
This is my third monitor, and here we go.
All right, we just need to add a line here so that it's readable, it was not really readable.
Let me clear all of this.
Here we go.
We are sending actually ultrasonic analog and the data and the scale to our cue.
Now, another test could come and just receive this and values.
That's a great we have learned now how we can send complex data to HQ in order to exchange it with other
tasks.