Finally, we can try out our transmitter node and see how we can communicate with the Arduino board
through the Ros.
Two topics.
In order to turn a Led on or off.
To do this.
First, let's connect the Arduino board to our PC using an USB cable.
Then open the Arduino IDE to check which port the board is connected to.
So in the tools.
Port.
In my case, this is the ACM zero port.
And then since we have already uploaded the code to the Arduino board in the previous lesson, we no
longer need the Arduino IDE so we can proceed to start our transmitter node, which reads the messages
from our ros2 topic and sends them through the serial port to the Arduino.
So let's open a new terminal and let's go to the workspace.
And here let's source the file setup dot bash.
So source the workspace and let's start our Ros two node with the command Ros two run and from the Arduino
bot firmware package.
Let's start the simple serial transmitter node.
Now with this, I'm going to start the cplusplus implementation of this node.
Otherwise, if you want to launch the Python implementation of this node, let's just type dot pi.
And so this one will launch the Pi implementation of this node.
Also before starting the node it needs to be configured, so we need to assign a value to the parameter
port.
So let's use the Ros args and then let's assign a parameter to the port.
And this is the port of your PC to which the Arduino is connected.
So in my case this is the M0 port, so let's press enter.
And upon starting this node it does nothing but initialize the serial communication with the Arduino
on the indicated port.
So on the ACM zero port.
Additionally, the node is also listening on a Ros two topic called Serial Transmitter.
In fact, if we open a new terminal and we execute the command Ros two topic list.
We can see that the serial transmitter topic exists and so we can use it to turn on or off the light
that is embedded in the board.
To do so, we can use the command Ros2 topic Poop.
And so let's publish a message on the serial transmitter.
Then let's press tab twice.
And then let's type the type of the interface.
So the standard message string that we are going to use in order to send messages within this topic,
then use the double quotes.
Then let's type the letter D and let's press tab again.
And so this will insert an empty prototype of the string message which we can publish on the serial
transmitter topic.
For example, let's turn on the led by publishing the value one on this topic.
So let's press enter.
And as soon as we do so we can see, we can interrupt this one.
We can see that the Led that is integrated into the board is on now is turned on.
If we send another message, for example, now let's send the message zero.
So let's send it.
And now we can see that as soon as we send this message, the lead that is embedded in the board is
turned off.