Statistics
| Branch: | Revision:

root / quad2 / arduino / src / main.cpp @ 98e35b23

History | View | Annotate | Download (515 Bytes)

1
#include "ArduinoHardware.h" // modified version in this directory
2
#include <ros.h>
3
#include <std_msgs/UInt16.h>
4

    
5
ros::NodeHandle nh;
6

    
7
std_msgs::UInt16 distance;
8
ros::Publisher range_up("range_up", &distance);
9
ros::Publisher range_down("range_down", &distance);
10

    
11
void setup()
12
{
13
  nh.initNode();
14
  nh.advertise(range_up);
15
  nh.advertise(range_down);
16
}
17

    
18
void loop()
19
{
20
  distance.data = analogRead(0);
21
  range_up.publish(&distance);
22
  distance.data = analogRead(1);
23
  range_down.publish(&distance);
24
  nh.spinOnce();
25
}