Show Posts
Pages: [1]
1  Using Arduino / Installation & Troubleshooting / Why do I need to keep pressing reset button on my UNO? on: June 20, 2011, 03:37:58 pm
Hi.

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:
Code:
//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
  Serial.begin(9600);
  //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;
  Serial.println(cm);
  delay(10);
}

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.

2  Using Arduino / Sensors / Uno + XL MaxSonar EZ1 MB1210 + Director 11.5 + Serial Xtra... on: June 15, 2011, 06:37:41 pm
Hi.

This is my first venture into Arduino so I'm a total n00b although I have messed with simple electronics many years ago. I'm trying to create a simple ultrasound sensor to drive computer-based installation. I got an Uno and a XL MaxSonar EZ1 MB1210 sensor and set it up as directed. It works! My code is below (adapted from Bruce Allen's original code):

Code:
//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
  Serial.begin(9600);
  //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;
  Serial.println(cm);
  delay(10);
}

I'm reading it from Adobe Director 11.5 using the Serial Xtra. The set up code is below:
Code:
on setUpSensor
  if objectP(gXtra) then
    gXtra.closePort()
    gXtra = VOID
  end if
  put new(xtra "SerialXtra","foo@whatever.com","XXXXXXXXXX",90) into gXtra
  if objectP(gXtra) then
    gxtra.OpenPort("COM3")  -- arduino
    gXtra.setProtocol(9600, "n", 8, 1)
  end if
end

The problem is that I have to press the reset button on the Arduino every time I run the Director code. It seems that as I am setting up comms to the board in this code it stops the Arduino board from running the sensor program on board. Anyone any ideas why? Sorry if this is simple - I couldn't find anything on this particular issue.

Thanks,  Paul.
Pages: [1]