I'm looking to change my program, but I don't know how.
As you can see in my program, I have to change manually (ctrol + maj + M ) the variables, but I have to enter these variables (with a delay):
In the end, I simply want to connect the arduino board to a non-arduino pc and the program works by automatically increasing the variables.
Thanks.
Prgm :
#include <Servo.h>
Servo esc;
Servo esc2;// Création de l'objet permettant le contrôle de l'ESC
int val = 0;
void setup() {
esc.attach(9); // On attache l'ESC au port numérique 9 (port PWM obligatoire)²
Serial.begin(9600);
esc2.attach(10);
Serial.begin(9600 );
// Quelques informations pour l'utilisateur
Serial.println("Saisir un nombre entre 0 et 179");
Serial.println("(0 = arret - 179 = vitesse maxi");
(" demarrage a partir de 20)");
}
void loop() {
if (Serial.available() > 0) {
val = Serial.parseInt(); // lecture de la valeur passée par le port série
Serial.println(val);
esc.write(val);
delay(15);
esc2.write(val);
delay(15);
}
}
i just want to increase the speed of my 2 engines (and esc) without having to fill in serial.print a value. I have to gradually increase the serialprint value to 170, without having to go from 20 to 170 otherwise it will not work.
#include <Servo.h>
Servo esc;
Servo esc2;// Création de l'objet permettant le contrôle de l'ESC
int val = 0;
void setup() {
esc.attach(9); // On attache l'ESC au port numérique 9 (port PWM obligatoire)²
Serial.begin(9600);
esc2.attach(10);
Serial.begin(9600 );
}
void loop() {
while (val < 170);
val = - ( millis()-start_time / 100;
esc.write(val);
esc2.write(val);
};
You need to tell us what is wrong. You usually do that by stating:
I expected FOO to happen.
When my sketch ran, BAR happened instead.
If necessary, describe how FOO and BAR are different.
Edit: If you have compiler errors, click the Copy error messages button and paste them here using code tags.
Edit2: Look up the syntax of the while instruction and note how it uses curly brackets.
Your syntax for the assignment of val is off.
When you do get the while loop figired out, you will probably want a delay in it to slowly move from one end of the range to the other.