Gerardo Hernandez / Mbed 2 deprecated SeaDragon0726

Dependencies:   mbed ros_lib_kinetic

Revision:
0:4735537ba7a7
Child:
1:62257cc9f659
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jul 25 20:39:56 2018 +0000
@@ -0,0 +1,46 @@
+#include "mbed.h"
+#include <ros.h>
+#include <std_msgs/Int16.h>
+#include <std_msgs/Bool.h>
+DigitalIn leakSensor(PC_2);
+DigitalIn killSwitch(PC_3);
+DigitalOut myled(LED1);
+ 
+ros::NodeHandle nh; 
+std_msgs::Bool leak_msg;
+ros::Publisher leak_publisher("leak", &leak_msg);
+std_msgs::Bool killSwitch_msg;
+ros::Publisher killSwitch_publisher("killSwitch", &killSwitch_msg);
+ 
+int main() 
+{
+    nh.initNode();
+    nh.advertise(leak_publisher);
+    nh.advertise(killSwitch_publisher);
+    
+    while (1)
+    {
+        if(leakSensor) 
+        {
+            leak_msg.data = 1;
+        }
+        else
+        {
+            leak_msg.data = 0;
+        }
+        leak_publisher.publish(&leak_msg);
+        
+        if(killSwitch) 
+        {
+            killSwitch_msg.data = 1;
+        }
+        else
+        {
+            killSwitch_msg.data = 0;
+        }
+        killSwitch_publisher.publish(&killSwitch_msg);
+        
+        nh.spinOnce();
+        wait_ms(200);
+    }
+}