-
Notifications
You must be signed in to change notification settings - Fork 0
/
arduino_node.ino
45 lines (37 loc) · 996 Bytes
/
arduino_node.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <ros.h>
#include <std_msgs/Float64.h>
#include <std_msgs/UInt16.h>
#include <std_msgs/String.h>
#include <HT1632.h>
ros::NodeHandle node;
std_msgs::String strdata;
ros::Publisher message("message",&strdata);
void temp_callback(const std_msgs::UInt16& temp){
char str[30];
sprintf(str,"Temperature: %d",temp);
strdata.data = str;
//HT1632.drawImage(str, 9, 9, 9, 9, 0);
//digitalWrite(13, HIGH-digitalRead(13));
message.publish(&strdata);
}
void volt_callback(const std_msgs::UInt16& volt) {
//char str[30];
//sprintf(str,"Voltage: %d",volt);
//HT1632.drawImage(str, 9, 9, 9, 9, 0);
digitalWrite(13, HIGH-digitalRead(13));
}
ros::Subscriber<std_msgs::UInt16> temp("temperature/integer", &temp_callback);
ros::Subscriber<std_msgs::UInt16> volt("voltage/integer", &volt_callback);
void setup()
{
pinMode(13, OUTPUT);
node.initNode();
node.advertise(message);
node.subscribe(temp);
node.subscribe(volt);
}
void loop()
{
node.spinOnce();
delay(1);
}