#include #include #include ros::NodeHandle nh; bool messageCb(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res) { digitalWrite(LED_BUILTIN, HIGH-digitalRead(LED_BUILTIN)); // blink the led nh.loginfo("LED is ON"); return true; } ros::ServiceServer blinkServer("/led/blink", &messageCb); void setup() { pinMode(LED_BUILTIN, OUTPUT); nh.initNode(); nh.advertiseService(blinkServer); } void loop() { digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(10); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(10); // wait for a second nh.spinOnce(); }