Why do I need to keep pressing reset button on my UNO?


This is a very lame question. I tried posting to the sensor forum but there isn't a single reply there! This is my first Arduino and the problem is that whenever I start communication with the board I seem to kill it - I need to push the rest button to get the program running. I'm reading input from a MaxSonar US sensor (EZ1 MB1210) and the code I'm using is simply:

//Digital pin 7 for reading in the pulse width from the MaxSonar device.
//This variable is a constant because the pin will not change throughout execution of this code.

const int pwPin = 7; 
//variables needed to store values
long pulse, cm;

void setup() {
  //This opens up a serial connection to shoot the results back to the PC console
  //Set up the input pin.
  pinMode(pwPin, INPUT);
void loop() {
  //Used to read in the pulse that is being sent by the MaxSonar device.
  //Pulse Width representation with a scale factor of 58uS per centimetre.
  pulse = pulseIn(pwPin, HIGH);
  //58uS per cm
  cm = pulse/58;

Every time I try to read it (in Director through the Serial Xtra) I need to push the reset button on the Arduino to start the on-board program to start passing out readings. Why? Do I need to prep the sensor somehow in the setup()?

Apologies for the lameness but any advice is really appreciated. Thanks.

The code looks fine but I would worry about flooding the serial line with too much data. Try changing your delay from 10 milliseconds to 3000 milliseconds (3 seconds between samples). If that prevents the failure you can try shorter delays until either you get the data as often as you need or the problem returns.