Automatic run - serial communication

Hello,

How do I get my program to run on the arduino UNO automatically once power is supplied? For programs like the "blink" sketch, the code runs automatically when the Arduino gets power. However, my program is using all serial communication between the Arduino and a stepper motor control box. I am unable to get the Arduino to transmit/receive information without clicking "serial monitor" on the software interface on my PC. Once I click "serial monitor", I can X out of the serial monitor box and the program runs until I disconnect power. This is not acceptable for my project as I want the Arduino to run in a remote location, powered by an AC/DC power converter plugged in to the wall. Please help???

Hunt

Hello,

hhaygood:
How do I get my program to run on the arduino UNO automatically once power is supplied?

That's how the Arduino works. Apply power and the program runs.

I am unable to get the Arduino to transmit/receive information without clicking "serial monitor" on the software interface on my PC.

Which indicates there is something special about your project. The goal is to determine what that is so you can get around the problem.

If you post your code it will be a lot easier to help :slight_smile:

Could noise or data on the RX line be preventing the bootloader from relinquishing control to the main program on reset? Maybe a pulldown resistor is needed.

So what I am trying to do is get the Arduino to read in a voltage value from a thermocouple and formulate a string output to a stepper motor control box, which in turn tells the stepper motor to move X amount of steps in order to turn the hand on a circular temperature dial.

The code looks like such..

void setup()
{
Serial.begin(9600);
}

//initial dial position
float prevVal=70;

void loop()
{
//reads in voltage from thermocouple
int sensorValue = analogRead(A0);
//converts arduino 0-1023 to voltage value
float voltVal = sensorValue0.004887585;
//converts voltage value to temperature value
float tempVal = 33.75
voltVal-33.75;
//converts temperature value to degrees temperature needed to move on temperature dial by finding the difference between the read in temperature and where the dial currently is
float tempDegreeMove=tempVal-prevVal;
//converts degrees temperature needed to move to circumferential degrees to move
float circumfDegreeMove-4.5tempDegreeMove;
//converts circumferential degrees to move to number of steps needed to move by stepper motor
int numSteps = circumfDegreeMove/1.8;
//saves the position the dial will move to in a moment.. reused on next loop iteration to calculate number of steps needed to move
prevVal=prevVal+(numSteps
(1.8/4.5);
int numStepsAbs = abs(numSteps);

if (numSteps > 0)
{
//creates string "@0+"
}
else
{
creates string "@0-"
}

//rest of code concatenates above strings with other strings for command to stepper motor control box, then..
Serial.println(stringFinal);
delay(10000);

}

The system needs to run without a computer; in other words, the Arduino is powered by a converter plugged in to a wall, as well as the temperature transmitter and other components. I have a TTL to RS-232 communication converter in order to talk between the Arduino UNO and the control box. The control box is powered by AC power directly from the wall. For some reason, I can't get the code to run automatically. I need that "Serial.println(stringFinal)" to transmit automatically without clicking "serial monitor" on my PC, because I want the system to run without the use of a PC.

Hunt

Why do you believe the code is not automatically running? Do you blink an LED in loop?

Are you sharing the serial output with the monitor and the motor controller?

I would suggest using the SoftwareSerial library and using a different set of pins. That frees the standard serial monitor for debugging. (And if your control box is sending characters down the serial, the Arduino bootloader might think it is trying to set up a download.)