Rosserial unable to connect to device

Hi!!

I have an arduino MEGA and I want to communicate via rosserial with my ros node.

Somewhere in my arduino code I have the following line:

if(intensity[n] <= myCounter) 
{
        digitalWrite((2*(n-8))+shiftSaidaInicial, LOW);
}

When I try to make the connection running rosrun rosserial_python serial_node.py /dev/ttyACM0 (used to connect the arduino via serial port) it says that it’s unnable to conenct to the device.

However, if I change the previous line to the following it syncs perfectly.

if(intensity[n] >= myCounter) 
{
        digitalWrite((2*(n-8))+shiftSaidaInicial, LOW);
}

The only thing I changed was the <= to >=. Sadly, so the code makes sense, I need the <= instead…

Anyone knows why this is happening?

Thanks!

What is rosserial?

And please post your complete program.

...R Python - Arduino demo