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.
Blink.cpp
00001 //#define COMPILE_BLINK_CODE_ROSSERIAL 00002 #ifdef COMPILE_BLINK_CODE_ROSSERIAL 00003 00004 /* 00005 * rosserial Subscriber Example 00006 * Blinks an LED on callback 00007 */ 00008 #include "mbed.h" 00009 #include <ros.h> 00010 #include <std_msgs/Empty.h> 00011 00012 ros::NodeHandle nh; 00013 DigitalOut myled(LED1); 00014 00015 void messageCb( const std_msgs::Empty& toggle_msg) { 00016 myled = !myled; // blink the led 00017 } 00018 00019 ros::Subscriber<std_msgs::Empty> sub("toggle_led", &messageCb ); 00020 00021 int main() { 00022 nh.initNode(); 00023 nh.subscribe(sub); 00024 00025 while (1) { 00026 nh.spinOnce(); 00027 wait_ms(1); 00028 } 00029 } 00030 00031 #endif
Generated on Sun Jul 17 2022 00:31:54 by
1.7.2