when i change the baudrate of the Arduino , wil the mhz change ??

ok this is the thing
i have a sketch working , i used a delay of 320 <delay (320);
the first time i used the script it worked
now i changed some smal things and now the delay hangs , or is not the same time i used before ?!@#
i also changed the serial output , and this phenomenom i seen before , when using serial.write
ok i know there is extra output when doing so , but changing the delay from 320 , to almost hanging state ??
do some one know this problem .,
or do i need to stay on 115200 baud for keeping the arduino running on same speed ?

i have a sketch

. . . but I'm not going to show it to you.

http://forum.arduino.cc/index.php?topic=257823

its here :D

Dexterbot: http://forum.arduino.cc/index.php?topic=257823

its here :D

Is there any chance you might post it properly without smileys, using code tags?

why are the smilies optional ? ]:smiley:

and what is a code tag ? lol
i found it thanks

// dexters KK2.0 automatic flight system //
// this wil be the automatic height control // 

#include <Servo.h> 
#include <NewPing.h> 
#define TRIGGER_PIN  3  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN     2  // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 400
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
// set height here //
const int height =40; // height set to 40 centimeter =+ -50 cm ,for trying to stay on 60 centimeter height //
const int auxset =1800;// aux output to kk2.0 for setting auto level onboard on or off !
int cm ; //incoming value of sensor
int safety =1; // safety switch value//
int sensor; // using this for sensoring inputs later on 
int auxv ; // Here's where we'll keep our aux channel values 1400 < autolevel off 1400 > = on
int auxs ; // Here i store input aux to servo output numbers  
int throtv ; // Here's where we'll keep our throttle channel values
int throts ; // Here i store  input throttle to servo output numbers 
int system ; // system for do stuf with throttle and height //
int mem1;
int mem2;
int sys;
int led = 13;
int piezo = 4;
// gimbal to horizontal and vertical pos readout //
// normal when start flying on the kk 2.0 the gimbal wil center its pos if used right //
int horim ; // using this for boxing the horizontal value from kk2.0
int vertm ; // using this for boxing the vertical value from kk2.0
int horiz ; // converting the horizontal input from kk2.0 to mapped value
int vertic ; // converting the vertical input from kk2.0 to mapped value
Servo throttle;  // make servo output to kk2.0 throttle input
Servo aux;       // make servo output to kk2.0 aux input
int signal =0; // signal procces 

void setup() {
  Serial.begin(9600); // starting my virtual serial port for APC220 wireles tx rx baud rate 9600 
  delay (2000); 
  aux.attach(7);   // servo conection out pin 7 to kk2.0 aux input //
  throttle.attach(smiley-cool; // servo conection out pin 8 to kk2.0 throttle input //
  aux.writeMicroseconds(auxset);   // set aux output to autolevel on on kk2.0 //
  pinMode(led, OUTPUT);
  pinMode(piezo, OUTPUT);
  pinMode(5, INPUT); // Set input channel for aux on pin 5 from rx //
  pinMode(6, INPUT); // Set input channel for throttle on pin 6 from rx //
  pinMode(9, INPUT); // Set input channel from gimbal horizontal pin 9 from rx for reading level //
  pinMode(10, INPUT); // Set input channel from gimbal vertical pin 10 from rx for reading level //
  digitalWrite(led, LOW);   // turn the LED on 
  digitalWrite(piezo, LOW);   // turn the PIEZO on 
  delay(1000);               // wait for a second
  digitalWrite(led, HIGH);   // turn the LED on 
  digitalWrite(piezo, HIGH);   // turn the PIEZO on 
  delay(1000);               // wait for a second
  digitalWrite(led, LOW); 
  //Serial.begin(9600); // start serial stuff build later on // 
  system = 0;
  throtv = pulseIn(6, HIGH, 20000); //checking throttle input
  auxv = pulseIn(5, HIGH, 20000); //checking throttle input
  if (throtv > 1025){ // if throttle is higher then 1000 then //
    throttle.writeMicroseconds(1000); // throttle on 0 before start 
    delay (1000); // this wil check if the throttle is above 0 then it wil delay 1 sec and prompt warning on serial output //
    Serial.println("8"); // warning mesage serial when 
    safety =1; // safety wil be fase 1 = disable trhottle input , and output 0 throttle  = disabled mode //
    return;
  }
  else if (throtv < 1025)
  {
    safety =2; // if input throttle = near 0 then safety wil be fase 2 = working quadcopter going to safety fase 3 later = flight mode //
  }
}
void loop() {
  throtv = pulseIn(6, HIGH, 20000); //checking throttle input
  auxv = pulseIn(5, HIGH, 20000); //checking throttle input
  // vertical and horizontal readout from gimbal output kk2.0 //
  // horim = pulseIn(9, HIGH, 20000); //checking gimbal horizontal input 
  // vertm = pulseIn(10, HIGH, 20000); //checking gimbal vertical  input 
  // horiz = map(vertm, 0, 20000, 0, 180); // mapping the horizontal value 
  // vertic = map(horim, 0, 20000, 0, 180); // mapping the vertical value 
  // this is the sonic sensor part for now , using the values for 433 mhz serial data and horizontal and vertical uav station //
  cm = sonar.ping();
  sensor = cm/ US_ROUNDTRIP_CM ;// converted duration from sensor to sensor cm value //ff //
  if (safety ==1){ // checking startup safety fase ,if fase = 1 then throttle wil be 0 and wil loop till reset button //
    delay (3000);
    return;
  }
  aux.writeMicroseconds(auxset);  // aux ON for autolevel kk2.0 conected to aux input //
  throtv = pulseIn(6, HIGH, 20000); //checking throttle input
  auxv = pulseIn(5, HIGH, 20000); // Read the pulse width of AUX input on pin 5 and store it in auxv int //
  auxs = auxv; // mapping the input of aux //
  throts = throtv  ; // mapping the input of throttle //
  if (auxv<1300){
    digitalWrite(led, HIGH);  
    system =throtv ; // telling the system the value of the throtle input 
    throttle.writeMicroseconds(throtv);  // write system speed to servo //  
    // if aux is off the input throttle = equal to input // 
    sys =throtv;
  }
  mem1 =sys;
  if(height<sensor){ // if sensor is higher then 1 meter //
    system = sys -1;
    throts = mem1;
    sys = constrain(system,1000,2000);
    throttle.writeMicroseconds(sys);  // write system speed to servo //
    delay (350);
  }
  else if(height>sensor){ // if sensor is lower then 1 meter //     
    system = sys +4;
    throts = mem1; // take speed DOWN by 1 digit of the system // 
    sys = constrain(system,1000,1730);
    throttle.writeMicroseconds(sys);  // write system speed to servo // 
}
}

this was not the advice i asked for ,, butt still a good answer !! :D i changed al my quote's to insert code !

The baudrate has no effect on the MHz rate of the clock.

I can't figure out what you mean by your delay() "hangs", especially as I can't see delay(320) anywhere in your code. (And I do know what hanging means in this context). How do you know it hangs? And on which line of the program does it hang?

Outside of setup() you should almost certainly replace all the delay()s with the millis() technique in the Blink Without Delay example sketch.

...R

i mean it wil hang , like the delay value is increased ,
i wil show you both scripts ,
the first one the delay did his job right , and i use serial .also

// dexters KK2.0 automatic flight system //
// this wil be the automatic height control // 

#include <Servo.h> 
#include <NewPing.h> 
#define TRIGGER_PIN  3  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN     2  // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 400
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
// set height here //
const int height =40; // height set to 40 centimeter =+ -50 cm ,for trying to stay on 60 centimeter height //
const int auxset =1800;// aux output to kk2.0 for setting auto level onboard on or off !
int cm ; //incoming value of sensor
int safety =1; // safety switch value//
int sensor; // using this for sensoring inputs later on 
int auxv ; // Here's where we'll keep our aux channel values 1400 < autolevel off 1400 > = on
int auxs ; // Here i store input aux to servo output numbers  
int throtv ; // Here's where we'll keep our throttle channel values
int throts ; // Here i store  input throttle to servo output numbers 
int system ; // system for do stuf with throttle and height //
int mem1;
int mem2;
int sys;
int led = 13;
int piezo = 4;
// gimbal to horizontal and vertical pos readout //
// normal when start flying on the kk 2.0 the gimbal wil center its pos if used right //
int horim ; // using this for boxing the horizontal value from kk2.0
int vertm ; // using this for boxing the vertical value from kk2.0
int horiz ; // converting the horizontal input from kk2.0 to mapped value
int vertic ; // converting the vertical input from kk2.0 to mapped value
Servo throttle;  // make servo output to kk2.0 throttle input
Servo aux;       // make servo output to kk2.0 aux input
int signal =0; // signal procces 

void setup() {
  Serial.begin(9600); // starting my virtual serial port for APC220 wireles tx rx baud rate 9600 
  delay (2000); 
  aux.attach(7);   // servo conection out pin 7 to kk2.0 aux input //
  throttle.attach(8); // servo conection out pin 8 to kk2.0 throttle input //
  aux.writeMicroseconds(auxset);   // set aux output to autolevel on on kk2.0 //
  pinMode(led, OUTPUT);
  pinMode(piezo, OUTPUT);
  pinMode(5, INPUT); // Set input channel for aux on pin 5 from rx //
  pinMode(6, INPUT); // Set input channel for throttle on pin 6 from rx //
  pinMode(9, INPUT); // Set input channel from gimbal horizontal pin 9 from rx for reading level //
  pinMode(10, INPUT); // Set input channel from gimbal vertical pin 10 from rx for reading level //
  digitalWrite(led, LOW);   // turn the LED on 
  digitalWrite(piezo, LOW);   // turn the PIEZO on 
  delay(1000);               // wait for a second
  digitalWrite(led, HIGH);   // turn the LED on 
  digitalWrite(piezo, HIGH);   // turn the PIEZO on 
  delay(1000);               // wait for a second
  digitalWrite(led, LOW); 
  //Serial.begin(9600); // start serial stuff build later on // 
  system = 0;
  throtv = pulseIn(6, HIGH, 20000); //checking throttle input
  auxv = pulseIn(5, HIGH, 20000); //checking throttle input
  if (throtv > 1025){ // if throttle is higher then 1000 then //
    throttle.writeMicroseconds(1000); // throttle on 0 before start 
    delay (1000); // this wil check if the throttle is above 0 then it wil delay 1 sec and prompt warning on serial output //
    Serial.println("8"); // warning mesage serial when 
    safety =1; // safety wil be fase 1 = disable trhottle input , and output 0 throttle  = disabled mode //
    return;
  }
  else if (throtv < 1025)
  {
    safety =2; // if input throttle = near 0 then safety wil be fase 2 = working quadcopter going to safety fase 3 later = flight mode //
  }
}
void loop() {
  throtv = pulseIn(6, HIGH, 20000); //checking throttle input
  auxv = pulseIn(5, HIGH, 20000); //checking throttle input
  // vertical and horizontal readout from gimbal output kk2.0 //
  // horim = pulseIn(9, HIGH, 20000); //checking gimbal horizontal input 
  // vertm = pulseIn(10, HIGH, 20000); //checking gimbal vertical  input 
  // horiz = map(vertm, 0, 20000, 0, 180); // mapping the horizontal value 
  // vertic = map(horim, 0, 20000, 0, 180); // mapping the vertical value 
  // this is the sonic sensor part for now , using the values for 433 mhz serial data and horizontal and vertical uav station //
  cm = sonar.ping();
  sensor = cm/ US_ROUNDTRIP_CM ;// converted duration from sensor to sensor cm value //ff //
  if (safety ==1){ // checking startup safety fase ,if fase = 1 then throttle wil be 0 and wil loop till reset button //
    delay (3000);
    return;
  }
  aux.writeMicroseconds(auxset);  // aux ON for autolevel kk2.0 conected to aux input //
  throtv = pulseIn(6, HIGH, 20000); //checking throttle input
  auxv = pulseIn(5, HIGH, 20000); // Read the pulse width of AUX input on pin 5 and store it in auxv int //
  auxs = auxv; // mapping the input of aux //
  throts = throtv  ; // mapping the input of throttle //
  if (auxv<1300){
    digitalWrite(led, HIGH);  
    system =throtv ; // telling the system the value of the throtle input 
    throttle.writeMicroseconds(throtv);  // write system speed to servo //  
    // if aux is off the input throttle = equal to input // 
    sys =throtv;
  }
  mem1 =sys;
  if(height<sensor){ // if sensor is higher then 1 meter //
    system = sys -1;
    throts = mem1;
    sys = constrain(system,1000,2000);
    throttle.writeMicroseconds(sys);  // write system speed to servo //
    delay (350);
  }
  else if(height>sensor){ // if sensor is lower then 1 meter //     
    system = sys +4;
    throts = mem1; // take speed DOWN by 1 digit of the system // 
    sys = constrain(system,1000,1730);
    throttle.writeMicroseconds(sys);  // write system speed to servo // 
}
}

and the one bellow i don’t use serial ,i tested a delay of 20 bellow in the sketch but no result , it hangs on same
time like 320 , or 1 , strange :astonished:
, and it wil increase the delay , real strange ,
when i take out the delay it wil work OK ,
but in the other one it works OK ,
i have this problem a LOTT whit other sketches ,
i also checked other boards , and the voltages for MHZ changes ,
it seems to have something to do whit serial out and bad rate ,
it also seems logical , when i do serial.begin 115200 and i write < hello dexter >>
it wil do this faster then 9600 , so doing delaying the next step , but normal this should not be noticable like
from 320 miliseconds to almost a delay of 1000 ±

//kk2.0 auto hoover // 1-8-2014//
#include <Servo.h> 
#include <NewPing.h> 
#define TRIGGER_PIN  3  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN     2  // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 400
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
// set height here //
const int height =25; // height set to 40 centimeter =+ -50 cm ,for trying to stay on 60 centimeter height //
const int auxset =1800;// aux output to kk2.0 for setting auto level onboard on or off !
int cm ; //incoming value of sensor
int safety =1; // safety switch value//
int sensor; // using this for sensoring inputs later on 
int auxv ; // Here's where we'll keep our aux channel values 1400 < autolevel off 1400 > = on
int auxs ; // Here i store input aux to servo output numbers  
int throtv ; // Here's where we'll keep our throttle channel values
int throts ; // Here i store  input throttle to servo output numbers 
int system ; // system for do stuf with throttle and height //
int mem1;
int mem2;
int sys;
int led = 13;
int piezo = 4;
// gimbal to horizontal and vertical pos readout //
// normal when start flying on the kk 2.0 the gimbal wil center its pos if used right //
int horim ; // using this for boxing the horizontal value from kk2.0
int vertm ; // using this for boxing the vertical value from kk2.0
int horiz ; // converting the horizontal input from kk2.0 to mapped value
int vertic ; // converting the vertical input from kk2.0 to mapped value
Servo throttle;  // make servo output to kk2.0 throttle input
Servo aux;       // make servo output to kk2.0 aux input
int signal =0; // signal procces 

void setup() {
  delay (2000); 
  aux.attach(7);   // servo conection out pin 7 to kk2.0 aux input //
  throttle.attach(8); // servo conection out pin 8 to kk2.0 throttle input //
  aux.writeMicroseconds(auxset);   // set aux output to autolevel on on kk2.0 //
  pinMode(led, OUTPUT);
  pinMode(piezo, OUTPUT);
  pinMode(5, INPUT); // Set input channel for aux on pin 5 from rx //
  pinMode(6, INPUT); // Set input channel for throttle on pin 6 from rx //
  pinMode(9, INPUT); // Set input channel from gimbal horizontal pin 9 from rx for reading level //
  pinMode(10, INPUT); // Set input channel from gimbal vertical pin 10 from rx for reading level //
  digitalWrite(led, LOW);   // turn the LED on 
  digitalWrite(piezo, LOW);   // turn the PIEZO on 
  delay(1000);               // wait for a second
  digitalWrite(led, HIGH);   // turn the LED on 
  digitalWrite(piezo, HIGH);   // turn the PIEZO on 
  delay(1000);               // wait for a second
  digitalWrite(led, LOW); 
  //Serial.begin(9600); // start serial stuff build later on // 
  system = 0;
  throtv = pulseIn(6, HIGH, 20000); //checking throttle input
  auxv = pulseIn(5, HIGH, 20000); //checking throttle input
  if (throtv > 1025){ // if throttle is higher then 1000 then //
    throttle.writeMicroseconds(1000); // throttle on 0 before start 
    delay (1000); // this wil check if the throttle is above 0 then it wil delay 1 sec and prompt warning on serial output //
    safety =1; // safety wil be fase 1 = disable trhottle input , and output 0 throttle  = disabled mode //
    return;
  }
  else if (throtv < 1025)
  {
    safety =2; // if input throttle = near 0 then safety wil be fase 2 = working quadcopter going to safety fase 3 later = flight mode //
  }
}
void loop() {
    if (safety ==1){ // checking startup safety fase ,if fase = 1 then throttle wil be 0 and wil loop till reset button //
    delay (3000);
    return;
  }
  throtv = pulseIn(6, HIGH, 20000); //checking throttle input
  auxv = pulseIn(5, HIGH, 20000); //checking throttle input
  // vertical and horizontal readout from gimbal output kk2.0 //
  // horim = pulseIn(9, HIGH, 20000); //checking gimbal horizontal input 
  // vertm = pulseIn(10, HIGH, 20000); //checking gimbal vertical  input 
  // horiz = map(vertm, 0, 20000, 0, 180); // mapping the horizontal value 
  // vertic = map(horim, 0, 20000, 0, 180); // mapping the vertical value 
  // this is the sonic sensor part for now , using the values for 433 mhz serial data and horizontal and vertical uav station //
  cm = sonar.ping();
  sensor = cm/ US_ROUNDTRIP_CM ;// converted duration from sensor to sensor cm value //ff //
  aux.writeMicroseconds(auxset);  // aux ON for autolevel kk2.0 conected to aux input //
  throtv = pulseIn(6, HIGH, 20000); //checking throttle input
  auxv = pulseIn(5, HIGH, 20000); // Read the pulse width of AUX input on pin 5 and store it in auxv int //
  auxs = auxv; // mapping the input of aux //
  throts = throtv  ; // mapping the input of throttle //
  if (auxv<1300){
    digitalWrite(led, HIGH);  
    system =throtv ; // telling the system the value of the throtle input 
    throttle.writeMicroseconds(throtv);  // write system speed to servo , if aux is off the input throttle = equal to input // 
    sys =throtv;
  }
  mem1 =sys;
  if(height<sensor){ // if sensor is higher then 1 meter //
    system = sys -1;
    throts = mem1;
    sys = constrain(system,1000,2000);
    throttle.writeMicroseconds(sys);  // write system speed to servo //
    delay (20);
  }
  else if(height>sensor){ // if sensor is lower then 1 meter //     
    system = sys +4;
    throts = mem1; // take speed DOWN by 1 digit of the system // 
    sys = constrain(system,1000,1740);
    throttle.writeMicroseconds(sys);  // write system speed to servo // 
}
}

You haven’t explained exactly what you mean by “it hangs”.

Do you mean that the call to delay() never completes - which is what I understand “hang” to mean?

Or do you mean that the delay() takes longer than you think it should? If so, how much longer?

Or, and this is a very different question, do you mean there is a change in the total timing for a piece of code that includes Serial.print() and delay()?

The logic of this seems to be back-to-front

when i do serial.begin 115200 and i write < hello dexter >> it wil do this faster then 9600 , so doing delaying the next step

I wonder if you have the wrong idea in your head of what the problem is and that is preventing you from looking at the problem with an open mind? (It happens to us all).

…R

Or, and this is a very different question, do you mean there is a change in the total timing for a piece of code that includes Serial.print() and delay()?

this also was the problem ,, when running script serial i found the problem ,, :astonished:

Dexterbot: i found the problem

Can you explain what it was for the benefit of others?

...R

it is the baudrate ,, and the serial begin ,, when i don't use serial begin ,, its normal when i use serial begin ,, it use the serial and baudrate i use , and this slowed the progress down , the other one is the fault in my sketch ,,