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
main.cpp
- Committer:
- florine_van
- Date:
- 2019-10-15
- Revision:
- 0:80d03f06b4ce
File content as of revision 0:80d03f06b4ce:
#include "mbed.h" #include <ros.h> #include <std_msgs/Empty.h> #include <std_msgs/Int32.h> ros::NodeHandle nh; DigitalOut myled(LED1); int speed; void toggleSpeed(const std_msgs::Int32& speed_) { speed = speed_.data; } ros::Subscriber<std_msgs::Int32> sub("motor_speed", &toggleSpeed); int main() { nh.initNode(); nh.subscribe(sub); while (1) { myled = !myled; nh.spinOnce(); if (speed <= 20){wait(2.0);} else if (speed <= 40){wait(1);} else if (speed <= 60){wait_ms(500);} else {wait_ms(100);} } }