Arduino dumilanove cannot read while writing?

i am a student in year 4 study in university. and im trying to use arduino board control a motor to move, but i want the motor to move only when i have received a analog signal.

but here is the problem: arduino cannot write anything while it is reading!?

everytime when i open the SerialPrint window, everything stoped?

it there any method that can get the analog read while the programe is running???

please please help! im failing my subject!

You're also failing to post any code. Over to you.

lk90lbc89: i am a student in year 4 study in university. and im trying to use arduino board control a motor to move, but i want the motor to move only when i have received a analog signal.

but here is the problem: arduino cannot write anything while it is reading!?

everytime when i open the SerialPrint window, everything stoped?

it there any method that can get the analog read while the programe is running????

please please help! im failing my subject!

Every time you open the serial port, the board resets... if you've read anything about Arduino or checked the schematic, you'd know this. It is possible to cut the track that does it, but then it is harder to transfer sketches to the Arduino. Seeedstudio provides a switch so you can do this without damaging the board.

The Serial isn't an analog value. Analog value is something that is read from the analog pins in the Arduino. Is that what you meant? The analogRead() function as far as I know doesn't stop the processing of the program in any perceptible way. Your problem is the auto-reset of the board.

If you post the code, it's simpler to understand what you're talking about.

int analogPin = 3;     // potentiometer wiper (middle terminal) connected to analog pin 3
                     
int val = 0;           // variable to store the value read

void setup()
{
  Serial.begin(9600); //  setup serial
  pinMode(3,OUTPUT);  
}

void loop()
{
  val = analogRead(analogPin);    // read the input pin
  Serial.println(val);      // debug value
  
  if (val>500){analogWrite(3,128);} 
}//i simplfied the code

Moderator edit: I added code tags.

When you want to post code… use the button with the # sign above the message box.

As I said… the auto-reset of the board causes it to stop. It is perceptible for a couple of seconds or so, but it then resumes. Not like your program is doing a lot either, is it?

Test your program with the serial port always open, then when you find that the program is good and finished, load it to the board and cut the auto-reset track. That will solve your problem. And create another to load new programs.

Code looks OK (ish). You realise digital pin 3 (where you analogWrite is going to) is a different pin to analogue input 3?

bubulindo: When you want to post code... use the button with the # sign above the message box.

As I said... the auto-reset of the board causes it to stop. It is perceptible for a couple of seconds or so, but it then resumes. Not like your program is doing a lot either, is it?

Test your program with the serial port always open, then when you find that the program is good and finished, load it to the board and cut the auto-reset track. That will solve your problem. And create another to load new programs.

thank you man

lk90lbc89:

bubulindo: When you want to post code... use the button with the # sign above the message box.

As I said... the auto-reset of the board causes it to stop. It is perceptible for a couple of seconds or so, but it then resumes. Not like your program is doing a lot either, is it?

Test your program with the serial port always open, then when you find that the program is good and finished, load it to the board and cut the auto-reset track. That will solve your problem. And create another to load new programs.

thank you man

but another thing is: when i open the serial port to AnalogRead() some value, there is only one number popping out then it stoped, forever stoped

Does your computer crash? sending values at that frequency would do that.

If you mean that the value is sent, but doesn't update when you move the potmeter... than looking at the hint AWOL left above will fix it for you...