Rosanswers logo

First off, I am Publishing String Data on a "set_pins_mode" topic. When I echo the topic, the data looks like this

Data: lights on

When I set up the arduino, everything seems to connect good but I am not getting an output. I believe it may be in the data structure or something. Here is my simplified arduino code.

#include <ros.h>
#include <std_msgs/String.h>

ros::NodeHandle  nh;

String Pin;

int Lights = 22;

void messageCb( const std_msgs::String& str_msg){

  Pin = str_msg.data;

ros::Subscriber(std_msgs::String)  sub("set_pins_mode", &messageCb);

void setup(){ 

  pinMode(13, OUTPUT);



  //Set all the pins we need to output pins
  pinMode(Lights, OUTPUT);

void loop()

  if (Pin = "light on"){

    digitalWrite(Lights, HIGH);
  if (Pin = "light off"){

    digitalWrite(Lights, LOW);



The program will get more complex with more lights added. I wanted to try and get one light working first, then its just a simple thing of copy/paste. I know this has to be easy. The output just doesn't come on.

Originally posted by matt2027 on ROS Answers with karma: 1 on 2012-04-26

Post score: 0

Original comments

Comment by matt2027 on 2012-04-28:
I've tried to setup Poark but I am getting this error.

/home/octavius/ros_workspace/poark/poark_server/poark_server.cpp:8:29: fatal error: ros/node_handle.h: No such file or directory compilation terminated.


2 Answers 2


Rosanswers logo

(Pin = "light off")

will do assignment rather than comparison (one '=' means assign). The fix:

(Pin == "light off")

I assume here that by "output" you mean the led changing.

Originally posted by Cody with karma: 125 on 2012-04-30

This answer was ACCEPTED on the original site

Post score: 2


Rosanswers logo

Hey Matt, I am the project maintainer of Poark. Please feel free to contact me if you have any troubles getting Poark compiled in the future.

For this particular case, can you be more specific about what steps have you taken to get the library compiled? Did you use the proper version of the rosserial code from the rosserial repository in our project (which is a compatible fork of the Parsec's rosserial port...which itself is an incompatible port of the original rosserial code)? I guess not using this version of resserial is the core of your problem but if this hint doesn't help just file an issue on our bug tracker and we'll try to help further.

Best, Julian

Originally posted by Jul with karma: 11 on 2012-04-29

This answer was NOT ACCEPTED on the original site

Post score: 1


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.