Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 43

Arduino Library not working with ROS

$
0
0
Hi all. I am using an LED library (Adafruit_NeoPixel) with ROS & an Arduino UNO. My LED code works without being connected to ROS. But once I connect it to ROS, the Arduino will not setup the led strip to the pin I set it to. It will only set up the pin if I directly set it up using pinMode. However, I can't use pinMode for an LED strip. I have to use a library. I tried three different libraries and all of them had the same problem. I'm pretty confident that the problem is setting up the pin through a library since all of my messages are being received fine. Any ideas on how to get my LED strip to light up when it's receiving messages? I'm attaching the test code I've been running to try to get my strip to light up. Thanks!!! #include #include #include ros::NodeHandle nh; Adafruit_NeoPixel strip = Adafruit_NeoPixel(240, 6, NEO_GRB + NEO_KHZ800); void messageCb(const std_msgs::Bool& toggle_msg){ strip.setPixelColor(1,strip.Color(0, 150,0)); strip.show(); } ros::Subscriber sub("toggle_msg", &messageCb ); void setup() { strip.begin(); strip.show(); nh.initNode(); nh.subscribe(sub); } void loop() { nh.spinOnce(); delay(1); }

Viewing all articles
Browse latest Browse all 43

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>