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.
main.cpp
00001 #include <ros.h> 00002 #include <std_msgs/Float32.h> 00003 #include <std_msgs/String.h> 00004 #include "SHARPIR.h" 00005 00006 00007 ros::NodeHandle nh; 00008 00009 std_msgs::Float32 data; 00010 ros::Publisher sharpir("sharpir", &data); 00011 00012 SHARPIR Sensor(A0); 00013 00014 00015 int main() { 00016 float DistanceCM; 00017 00018 nh.initNode(); 00019 nh.advertise(sharpir); 00020 00021 while (1) { //creates an eternal loop 00022 00023 DistanceCM=Sensor.cm(); 00024 //sprintf (buffer, "%f", DistanceCM); 00025 00026 data.data = DistanceCM; 00027 sharpir.publish( &data ); 00028 00029 nh.spinOnce(); 00030 wait_ms(1000); 00031 } 00032 }
Generated on Thu Jul 14 2022 13:04:31 by
