Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed ros_lib_kinetic
Diff: main.cpp
- Revision:
- 0:bd7941d8c490
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Oct 16 09:18:47 2019 +0000 @@ -0,0 +1,26 @@ +/* + * rosserial Subscriber Example + * Blinks an LED on callback + */ +#include "mbed.h" +#include <ros.h> +#include <std_msgs/Empty.h> + +ros::NodeHandle nh; +DigitalOut myled(LED1); + +void messageCb(const std_msgs::Empty& toggle_msg){ + myled = !myled; // blink the led +} + +ros::Subscriber<std_msgs::Empty> sub("toggle_led", &messageCb); + +int main() { + nh.initNode(); + nh.subscribe(sub); + + while (1) { + nh.spinOnce(); + wait_ms(1); + } +} \ No newline at end of file