Doesn't work Ros's Push Button with Arduino

Hello,

i am doing this example: http://ros.informatik.uni-freiburg.de/roswiki/rosserial_arduino(2f)Tutorials(2f)Push(20)Button.html

So, i have make the same circuit of this example but connecting the button to the pin 7.

But when i run rostopic echo chatter i don't any information.

Why? Thanks.

Why do you mix two examples ? They are slightly different.

And may I say, they both look more complicated than they should be. Reading a simple button can be done by just a digitalRead().

Why do you use the ROS echo chatter ? That makes it even more complicated.

Did you use the build-in examples of the Arduino ? They are not complicated and they invite you to alter them to understand it.
How do you want to wire your button ?
A button is mostly connected to ground with a pull-up resistor to 5V. If that is used, a digitalRead() will read a LOW if the button is pressed and HIGH if the button is not pressed.

You also have to use a multimeter to see which pins of the button connect. If you rotate it 90 degrees it is not working.

I am testing Rosserial library, so i would like to do this exercise. But the circuit is not very good explain in the website.

I have uploaded a picture

So, i have make the same circuit of this example but connecting the button to the pin 7.

Why do you say "but" - he connects to pin seven too.

How did you get the soft-focus effect?

Can you post your code?
Have you tried a really simple loop that just prints the value returned by a digitalRead of your button pin?

 * Button Example for Rosserial
 */

#include <ros.h>
#include <std_msgs/Bool.h>


ros::NodeHandle nh;

std_msgs::Bool pushed_msg;
ros::Publisher pub_button("pushed", &pushed_msg);

const int button_pin = 7;
const int led_pin = 13;

bool last_reading;
long last_debounce_time=0;
long debounce_delay=50;
bool published = true;

void setup()
{
  nh.initNode();
  nh.advertise(pub_button);
  
  //initialize an LED output pin 
  //and a input pin for our push button
  pinMode(led_pin, OUTPUT);
  pinMode(button_pin, INPUT);
  
  //Enable the pullup resistor on the button
  PORTD |= (1<<PD7);
  
  //The button is a normally button
  last_reading = ! digitalRead(button_pin);
 
}

void loop()
{
  
  bool reading = ! digitalRead(button_pin);
  
  if (last_reading!= reading){
      last_debounce_time = millis();
      published = false;
  }
  
  //if the button value has not changed for the debounce delay, we know its stable
  if ( !published && (millis() - last_debounce_time)  > debounce_delay) {
    digitalWrite(led_pin, reading);
    pushed_msg.data = reading;
    pub_button.publish(&pushed_msg);
    published = true;
  }

  last_reading = reading;
  
  nh.spinOnce();
}
const int button_pin = 7;

void setup()
{
  pinMode(button_pin, INPUT);
  digitalWrite (button_pin, HIGH);
  Serial.begin (9600);
}

void loop()
{
  Serial.println (digitalRead (buttonPin));
  delay (100);
}

Please use code tags when posting code.