Personal fork
Dependencies: Servo mbed rosserial_mbed_lib
Fork of rosserial_mbed by
Diff: examples/Blink.cpp
- Revision:
- 0:06fc856e99ca
- Child:
- 5:e52b44294b2b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/Blink.cpp Fri Aug 19 09:06:16 2011 +0000 @@ -0,0 +1,31 @@ +//#define COMPILE_BLINK_CODE_ROSSERIAL +#ifdef COMPILE_BLINK_CODE_ROSSERIAL + +/* + * 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); + } +} + +#endif \ No newline at end of file